Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do -- cham_stuff
- cham_stuff = {
- enabled = false,
- ally_chams = true,
- cham_folder = Instance.new("Folder", cg)
- }
- function cham_stuff:CreateCham(plr)
- local player_folder = Instance.new("Folder", self.cham_folder)
- player_folder.Name = tostring(plr)
- local char = plr.Character or plr.CharacterAdded:wait()
- local tor = char:WaitForChild("HumanoidRootPart")
- local hum = char:WaitForChild("Humanoid")
- for i, v in pairs(char:GetChildren()) do
- if v:IsA("PVInstance") and v.Name ~= "HumanoidRootPart" then
- local box = Instance.new("BoxHandleAdornment")
- box.Size = functions:GetSizeOfObj(v)
- box.Name = "Cham"
- box.Adornee = v
- box.AlwaysOnTop = true
- box.ZIndex = 5
- box.Transparency = self.enabled and 0.5 or 1
- box.Color3 = functions:GetTeamColor(plr)
- box.Parent = player_folder
- end
- end
- plr.CharacterRemoving:connect(function()
- self:RemoveCham(plr)
- plr.CharacterAdded:wait()
- self:CreateCham(plr)
- end)
- hum.Died:connect(function()
- self:RemoveCham(plr)
- plr.CharacterAdded:wait()
- self:CreateCham(plr)
- end)
- end
- function cham_stuff:RemoveCham(plr)
- local find = self.cham_folder:FindFirstChild(tostring(plr))
- if find then
- find:Destroy()
- end
- end
- function cham_stuff:UpdateChamColor(plr)
- local player_folder = self.cham_folder:FindFirstChild(tostring(plr))
- if player_folder then
- local color = functions:GetTeamColor(plr)
- for i, v in pairs(player_folder:GetChildren()) do
- v.Color3 = color
- end
- end
- end
- function cham_stuff:SetTrans(trans, player_folder)
- for i, v in pairs(player_folder:GetChildren()) do
- v.Transparency = trans
- end
- end
- function cham_stuff:UpdateCham(plr, ignorelist)
- local player_folder = self.cham_folder:FindFirstChild(tostring(plr))
- if player_folder then
- if not self.enabled then return self:SetTrans(1, player_folder) end
- local char = plr.Character
- if not self.ally_chams and plr.Team == p.Team then
- return self:SetTrans(1, player_folder)
- end
- if c and char then
- local their_head = char:FindFirstChild("Head")
- local their_tor = char:FindFirstChild("HumanoidRootPart")
- local their_hum = char:FindFirstChild("Humanoid")
- local my_head = c:FindFirstChild("Head")
- local my_tor = c:FindFirstChild("HumanoidRootPart")
- if their_hum then
- if their_hum.Health <= 0 then
- return self:SetTrans(1, player_folder)
- end
- end
- if their_head and their_tor and my_head and my_tor then
- if (my_tor.Position - their_tor.Position).magnitude > 2048 then
- return self:SetTrans(1, player_folder)
- end
- --raycast(workspace,Ray.new(client.camera.cframe.p,rel),ignorelist)
- local p = workspace:FindPartOnRayWithIgnoreList(Ray.new(client.camera.cframe.p, (their_head.Position - client.camera.cframe.p)), ignorelist)
- if p then
- return self:SetTrans(0, player_folder)
- else
- return self:SetTrans(0.3, player_folder)
- end
- end
- end
- return self:SetTrans(0, player_folder)
- end
- end
- function cham_stuff:Init()
- functions:RunLoop("Cham_Update", function()
- local ignorelist = {c, ca, workspace.Ignore}
- for i, v in pairs(ps:GetPlayers()) do
- ignorelist[#ignorelist+1] = v.Character
- end
- for i, v in pairs(ps:GetPlayers()) do
- self:UpdateCham(v, ignorelist)
- end
- end, r.RenderStepped)
- for i, v in pairs(ps:GetPlayers()) do
- if v ~= p then
- spawn(function()
- self:CreateCham(v)
- end)
- v.Changed:connect(function(prop)
- self:UpdateChamColor(v)
- end)
- end
- end
- ps.PlayerAdded:connect(function(plr)
- self:CreateCham(plr)
- plr.Changed:connect(function(prop)
- self:UpdateChamColor(plr)
- end)
- end)
- ps.PlayerRemoving:connect(function(plr)
- self:RemoveCham(plr)
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement