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

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

Asked by 4 years ago

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

Log in to vote
2
Answered by 4 years ago

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

0
Thanks a million! EpicEndoskeleton 2 — 4y
1
EpicEndoskeleton, It is not fair for using bibi0629's answer and NOT accepting it. Please consider doing it. rayhansatria 142 — 4y
0
I agree with you^ SUPERMEGADANTHEMAN 33 — 4y
0
I'm sorry, I didn't realise there was an accept button, thanks for reminding me! EpicEndoskeleton 2 — 4y
Ad

Answer this question