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

How to make a click detector play a sound when clicked?

This is the script:

game.Workspace.clickdetectorevent.OnServerEvent:Connect(function()
	local button = script.Parent.Parent.Model.Button
	local door = script.Parent.Parent.Door
	
	button.BrickColor = BrickColor.Black()
	button.Transparency = 0.5
	door.CanCollide = false
	door.Transparency = 0.6
	script.Parent.Parent.Model.Button.beep.play()
	wait(3)
	
	button.BrickColor = BrickColor.Red()
	button.Transparency = 0
	door.CanCollide = true
	door.Transparency = 0
	
	
end)

I'm very new to scripting, and I can't figure out how to play a sound (the sound is named beep) I'm sorry if there's some sort of obvious error, like I stated before, I'm very new and any piece of advice or help is greatly appreciated.

1 answer

✓ Accepted answer

replace line 9

	    script.Parent.Parent.Model.Button.beep.play() -- the dot should be replaced with a ":"

with

	    script.Parent.Parent.Model.Button.beep:Play()

sound:play()

4 comments

0

Thanks a million!

1

EpicEndoskeleton, It is not fair for using bibi0629's answer and NOT accepting it. Please consider doing it.

0

I agree with you^

0

I'm sorry, I didn't realise there was an accept button, thanks for reminding me!

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