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

My player won't sit when touching a part?

Asked by 4 years ago

My player won't sit when touching a part(More specifically a union).

Here's the code:

script.Parent.Touched:Connect(function(hit)
    game:GetService("Players").LocalPlayer.Humanoid.Sit = true
end)

Can someone explain this issue? Thanks if you can.

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

LocalPlayer is only used for local scripts , game:GetService("Players") isn't necessary.

If you want the script to work then try this:

script.Parent.Touched:Connect(function(hit)      
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:FindFirstChild("Humanoid").Sit=true
    end 
end)

hit.parent is basically the player who touched it.

Ad

Answer this question