Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Clothing and Kill script need editing for group purpose, anyone know how?

Asked by 6 years ago
script.Parent.Touched:connect(function(hit) 
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum ~= nil then
        local rank = game.Players[hit.Name]:GetRankInGroup(groupid) 
        if rank == "" then

        end
    end
end)

I need this implementing so that when you touch the brick it kills you if not between the given ranks in the specific group.

pnts = script.Pants
shirt = script.Shirt

function GiveClothes(character)
if not character:findFirstChild("Shirt") then 
shirt:Clone().Parent = character
else character:findFirstChild("Shirt"):Destroy()
shirt:Clone().Parent = character
end

if not character:findFirstChild("Pants") then 
pnts:Clone().Parent = character
else character:findFirstChild("Pants"):Destroy()
pnts:Clone().Parent = character
end
end

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(char)
wait(1.12)
local plr = game.Players:findFirstChild(char.Name)
print(char.Name)

if plr.TeamColor ~= BrickColor.new("Dark blue") then 
return
else GiveClothes(char)
end
end)
end)

This script has a similar issue, it works and gives the players the correct clothes but I need to edit it so that if you are a specific rank in a group your given a different set of clothes, it could be in multiple scripts.

1 answer

Log in to vote
0
Answered by 6 years ago

You need to put an if statement with the condition of it being between the ranks specified. If true, give them the clothing. Else, kill them. This is very simple.

script.Parent.Touched:connect(function(hit) 
    local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum ~= nil then
        local rank = game.Players[hit.Parent.Name]:GetRankInGroup(groupid) 
        if rank == 18 then -- If they are rank 18. This if statement checks for a single rank, use it if you only want a single rank
            GiveClothes(hit.Parent)
        elseif rank>= 10 and rank<=20 then -- If they are between rank 10 and 20 (Inclusive), use it if you want a range
            GiveClothes(hit.Parent) -- give them clothing

        else -- If they are not
            hit.Parent:BreakJoints() -- Kill them

        end
    end
end)


I hope I helped, andhave a good day!

Ad

Answer this question