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

What is this "Part" Parameter in the script?

Asked by 8 years ago

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

0
"(part)" is the part that touched this part. "part.Parent:FindFirstChild("Humanoid")" checks if there is an humanoid. if there is one, it kills the model. haloelite27 25 — 8y

2 answers

Log in to vote
0
Answered by
rexbit 707 Moderation Voter
8 years ago
Edited 8 years ago

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.

0
Ok. Can you explain arguments and parameters. I do not get them. vinniehat54 18 — 8y
0
Simple. Think of both as variables, a parameter is a variable without value(ex. local Variable) and an agrument is a variable with value(ex. local Variable = "string". rexbit 707 — 8y
0
Thanks! So the parameter "part" has nothing to do with the part in part.Parent:FindFirstChild("Humanoid") ~= nil then? vinniehat54 18 — 8y
0
It does. I don't know why it wouldn't? rexbit 707 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
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)

0
Ok. Thank you. But I do not get the parameters for "part". Can you explain Parameters to me? vinniehat54 18 — 8y

Answer this question