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

What's wrong with this sit script?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
script.Parent.ChildAdded:connect(function(player)
if ClassName == "Weld" then 
 Player = game.Players:GetPlayerFromCharacter(Child.Part1.Parent)
    if Player then
    print("A player has sat!")

end 


end 





end)
0
I have no idea what script.Parent is for, or where it is, so I have no idea. Adryin 120 — 10y
0
For the seat ITSolarWinds 25 — 10y
0
The Humanoid of the character has a bool value of Sit. Use that. Orlando777 315 — 10y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

You have not defined ClassName, so it will be always be nil. This means the condition on line 2 will always fail, since nil ~= "Weld".

The parameter to ChildAdded would be well called Child, like you use on line 3.

ClassName would then have the value of Child.ClassName.


script.Parent.ChildAdded:connect(function(Child)
    if Child.ClassName == "Weld" then 
        Player = game.Players:GetPlayerFromCharacter(Child.Part1.Parent)
        if Player then
            print("A player has sat!")
        end 
    end 
end)
Ad

Answer this question