Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

LocalScript only plays at me, not to other players, how to fix it?

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)

5 comments

0

I dont think you need to use a local script for this purpose. I think this might be the issue, since the local script is only running the sound for the one "client" or player. Try transferring this to a script and try

0

Because when using a script, the server will ensure all players will be able to see, or hear the change in this instance

0

Attempt changing this to a Server Script and see if that fixes the issue.

0

Local script is for a client, you should use a normal script so everyone could hear it. Besides, on line 8, that is 'script.Parent.Parent.script.Parent', that doesn't make sense...

0

basically, the script is on the sound

1 answer


Note

If you see any text in blue, it's a line of text you can click to open a link.


Local Scripts

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.


Server Script

Otherwise known as a regular script is a script that interacts with the Server which those effects transfer to all the clients.


Your Error

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.


Your Script

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)

1 comment

0

I'm new at scripting and the script I sent didn't make sense and it didn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.