Hi, I am making a group rank door. Only certain ranks or above can go through. But if not the right rank, I want the person to be killed to be set back to spawn. I have it working, but I need helping understanding certain parts.
function onTouched(part) -- part? What is that? I know it is a Parameter. What does it do? if game.Players.LocalPlayer:GetRankInGroup(2934469) >= 10 then script.Parent.CanCollide = false elseif part.Parent:FindFirstChild("Humanoid") ~= nil then -- part here? What does it do? part.Parent.Torso:BreakJoints() -- part here? What does it do? end end script.Parent.Touched:connect(onTouched)
Thanks, Vincent Lauro
The Part
is actually an argument, a parameter with value, Part
returns any objects that are 'touching' the main Basepart, in this case, a group rank door.
Line 4 checks if the player has a Humanoid if it returns true then it breaks it's joints by using the method BreakJoints
, what BreakJoints
does is it dismantles any connected part(Welds/Joints), now that only occurs if the player's ranking is not above 10 because of that elseif
statement.
function onTouched(part) -- part is the part that the script's parent touched if game.Players.LocalPlayer:GetRankInGroup(2934469) >= 10 then script.Parent.CanCollide = false elseif part.Parent:FindFirstChild("Humanoid") ~= nil then -- This looks to see if the part's parent contains a Humanoid part.Parent.Torso:BreakJoints() -- This kills the player if they don't have a high enough rank. It breaks the joints of the character's Torso end end script.Parent.Touched:connect(onTouched)