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

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

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

✓ Accepted answer
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)

2 comments

0

does not work

0

try again ... i made a mistake

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