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

I have 2 bricks that play audio once And I click the 1 brick that plays audio the other does not?

Asked by 4 years ago

I have 2 bricks that play audio once

local CD = script.Parent.ClickDetector
local Part = script.Parent
local Sound = script.Parent.Sound

game.Players.PlayerAdded:Connect(function(plr)
    local HasClicked = Instance.new("BoolValue")
    HasClicked.Name = 'HasClicked'
    HasClicked.Parent = plr
end)




CD.MouseClick:Connect(function(player)
    if player.HasClicked.Value == false then
        Sound.Playing = true
        player.HasClicked.Value = true
    else
        print('No you have clicked this')
    end
end)

And if I click the 1 brick that plays audio the other one does not

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local CD = script.Parent.ClickDetector
local Part = script.Parent
local Sound = script.Parent.Sound
local Clicked = {}

game.Players.PlayerAdded:Connect(function(plr)
Clicked[plr.UserId] = false
end)

CD.MouseClick:Connect(function(plr)
if Clicked[plr.UserId] == false then
Clicked[plr.UserId] = true
Sound:Play()
else
print("You have already clicked ...")
end
end)

0
does not work ConorPodboy 14 — 4y
0
try again ... i made a mistake Harry_TheKing1 325 — 4y
Ad

Answer this question