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

How To Fix My Door That Make Sound When Click?

Asked by
ImfaoXD 158
8 years ago

I made a door that make sound when someone click on it. And I also added in a code that when someone say like "open up" the door will open, but it's not working. Can someone help me?

Here is my door and script layout so it's easier to know what I'm talking about:

https://gyazo.com/d9201224b982036726ea59de40e8b3e1

And my script is down below:

Brick = script.Parent
Sound = Brick.Sound
Debounce = false

function onClicked()
    if not Debounce then -- If the debounce is false
        Debounce = true -- Change it to true
        Sound:Play()
        wait(Sound.TimeLength) -- Wait til it ends
        Debounce = false -- Change it to false
    end -- End the if function
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

door = script.Parent --this is the door 

function onChatted(msg, recipient, speaker) 

-- convert to all lower case 

local source = string.lower(speaker.Name) 
msg = string.lower(msg) 

if (msg == "open up") then 
door.CanCollide = false 
door.Transparency = 0.7 
wait(5) 
door.CanCollide = true 
door.Transparency = 0 
end 

end 

function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered) 

0
What isn't working? Are there errors? Is it the sound that's breaking? darkelementallord 686 — 8y
0
No, there's no error when I check my output. D: ImfaoXD 158 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

The problem may be due to the fact that you're using a LocalScript, I'd recommend using normal scripts when they are being run serverside.

Ad

Answer this question