Hello! So am making a localscript where if the player touched a part/hitbox it would play a sound. But if one plays it then it plays for everyone? how would I fix that
localscript:
local Arcade = game.Workspace.Arcade
local ArcadeHitBox = Arcade.Hitbox
local Arcade2 = game.Workspace.Arcade2
local ArcadeHitBox2 = Arcade2.Hitbox
local Freddy = game.Workspace.Freddy
local FreddyHitBox = Freddy.Hitbox
local Debounce = false
local Debounce2 = false
ArcadeHitBox.Touched:Connect(function(player)
if Debounce == false then
Debounce = true
Arcade.Arcade.Screen.Color = Color3.new(1, 1, 1)
local Sound = math.random(1,3)
if Sound == 1 then
player.PlayerGui.GlitchEffect.Glitch:Play()
elseif Sound == 2 then
player.PlayerGui.GlitchEffect.Glitch2:Play()
elseif Sound == 3 then
player.PlayerGui.GlitchEffect.Glitch3:Play()
end
wait(3)
script.Parent.Glitch:Stop()
script.Parent.Glitch2:Stop()
script.Parent.Glitch3:Stop()
Arcade.Arcade.Screen.Color = Color3.new(0, 0, 0)
Debounce = false
ArcadeHitBox.Parent = script
wait(30)
script.Hitbox.Parent = Arcade
end
end)
ArcadeHitBox2.Touched:Connect(function(player)
if Debounce == false then
Debounce = true
Arcade2.Arcade.Screen.Color = Color3.new(1, 1, 1)
local Sound = math.random(1,3)
if Sound == 1 then
player.PlayerGui.GlitchEffect.Glitch:Play()
elseif Sound == 2 then
player.PlayerGui.GlitchEffect.Glitch2:Play()
elseif Sound == 3 then
player.PlayerGui.GlitchEffect.Glitch3:Play()
end
wait(3)
script.Parent.Glitch:Stop()
script.Parent.Glitch2:Stop()
script.Parent.Glitch3:Stop()
Arcade2.Arcade.Screen.Color = Color3.new(0, 0, 0)
Debounce = false
ArcadeHitBox2.Parent = script
wait(30)
script.Hitbox.Parent = Arcade2
end
end)
FreddyHitBox.Touched:Connect(function(player)
if Debounce == false then
Debounce = true
local Sound = math.random(1,3)
if Sound == 1 then
player.PlayerGui.GlitchEffect.Glitch:Play()
elseif Sound == 2 then
player.PlayerGui.GlitchEffect.Glitch2:Play()
elseif Sound == 3 then
player.PlayerGui.GlitchEffect.Glitch3:Play()
end
wait(3)
script.Parent.Glitch:Stop()
script.Parent.Glitch2:Stop()
script.Parent.Glitch3:Stop()
Debounce = false
FreddyHitBox.Parent = script
wait(30)
script.Hitbox.Parent = Freddy
end
end)