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

I am trying to use a touched event to make the character sit, but it doesn't work?

Asked by 4 years ago

This is in a localscript inside a part. not a seat part, just a normal part.

local seat = script.Parent


seat.Touched:Connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")

    humanoid.HumanoidStateType = Enum.HumanoidStateType.Seated

end)
0
what are you using this for lon233bcc 31 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

"local script" you cant use the touched effect in local script try a normal one also heres a little edit of this code (should prevent errors if the thing that touches it doesnt have humanoid)

local seat = script.Parent


seat.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    humanoid.HumanoidStateType = Enum.HumanoidStateType.Seated
    end
end)
Ad

Answer this question