Basically, I have a localscript for my Vehicleseat so that it can play engine sounds when I sit on it, the only problem is that only the player who sits in the Vehicleseat can hear the engine sound, is there a way to solve this?
local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local seat = script.Parent.Parent local sound = script.Parent function onSeated(isSeated, seat) if isSeated then seat.sound:Play() end end humanoid.Seated:Connect(onSeated)
If you see any text in blue, it's a line of text you can click to open a link.
I believe you have been misinformed or you misunderstood what a LocalScript is for. A summary would be the following; a local script is a script that interacts with the Client, not the server.
Otherwise known as a regular script is a script that interacts with the Server which those effects transfer to all the clients.
As you can see in your script, you contradict your value seat
with Line 3 local seat = script.Parent.Parent
and Line 6 function onSeated(isSeated, seat)
, the seat in line 3 is a defined variable, however in Line 6, you turn it into a variable for that function which removes Line 3's purpose.
I have not tested this so it may not work,however it's worth the try TURN THIS INTO A SERVER SCRIPT IF YOU CAN, THERE'S NO REASON FOR IT TO BE A LOCAL SCRIPT.
local character = script.Parent local humanoid = character:WaitForChild("Humanoid") local seat = script.Parent.Parent local sound = script.Parent function onSeated(isSeated) if isSeated then seat.sound:Play() end end humanoid.Seated:Connect(onSeated)