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

why does .touched not work in this script, typing extra in order to be able to post?

Asked by 4 years ago

this code is just not working. no error is being output.

seat = workspace.seatpart


seat.Touched:Connect(function(hit)
    print("sat in the seat")
end)

2 answers

Log in to vote
0
Answered by
Psudar 882 Moderation Voter
4 years ago

This could be for a number of reasons. I think its probably likely that you're using a local script inside of the seat, local scripts dont run unless they're replicated to the player somewhere.

If you switch to a server script, this should most definitely work.

--server script inside a seat

script.Parent.Touched:Connect(function()
    print("x")
end)

Output: x(x20)

Ad
Log in to vote
0
Answered by 4 years ago

Like Psudar said, there could be several mistakes that maybe you didn't realize you made.

Check that when typing, workspace doesn't need a capital W.

Instead of just 'workspace', type game.workspace otherwise the computer might be confused, thinking that you might be defining another variable or something.

Also check that the seat is called 'seatpart'. If you've just copied the script from a pastebin or something, this could've been why. Otherwise the computer again, might think you're trying to define something else.

Finally, make sure the seat is the right way round! Rotate it and flip it if your character is not sitting on it, and if you've put the seat into a union you'll have to separate it because the seat loses its properties.

Any more error codes, reply to the message, otherwise, I hope this helps! ????

Answer this question