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

Sound won't play when player sits in car?

Asked by
baxzzi 42
6 years ago

Hi, I'm currently stuck on a problem that I can't figure out myself. I want the localscript to play a sound locally whenever a player enters the car. The script looks for when a child is added into the "DriveSeat" and detects whether it is a "Weld" or not. If it is a "Weld" then it should play a specific sound. All sounds are under the drive seat and the script is a localscript as I mentioned before. The car chassis is Inspare SS3. Anyway, here is the script I'm working with, it's fairly simple.


local carSeat = script.Parent script.Parent.ChildAdded:connect(function(child) if child:IsA("Weld") then carSeat.Startup:Play() wait(1) carSeat.Chime:Play() end
0
Two problems with your script: 1 On line 4 use Connect instead of connect since it is deprecated. 2 You never ended your ChildAdded event. Add a line and type "end)" zblox164 531 — 6y
0
Hmm, still doesn't work I've done everything you said to do. baxzzi 42 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Seeing your script and its ancestry, the LocalScript is a child of a BasePart. Sad to say, that LocalScript objects can only run if under one of the following:

- Backpack

- PlayerGui

- PlayerScripts

- Player’s Character

- ReplicatedFirst service.

Convert your script into a server script, and use SoundService:PlayLocalSound(Sound) to play a sound locally.

0
Ah, good tip for the future and I'll defiently keep this for reference later. I'll try this in the morning tomorrow. But thanks! baxzzi 42 — 6y
Ad

Answer this question