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

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

Asked by 4 years ago

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)
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 spot6003 64 — 4y
0
Because when using a script, the server will ensure all players will be able to see, or hear the change in this instance spot6003 64 — 4y
0
Attempt changing this to a Server Script and see if that fixes the issue. Just2Terrify 566 — 4y
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... naturedat 124 — 4y
0
basically, the script is on the sound Gam3r_Play3r 47 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

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)
0
I'm new at scripting and the script I sent didn't make sense and it didn't work Gam3r_Play3r 47 — 4y
Ad

Answer this question