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

Sound won't play when player sits in car?

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

2 comments

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)"

0

Hmm, still doesn't work I've done everything you said to do.

1 answer

✓ Accepted answer

###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.

1 comment

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!

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