This script is supposed to play client sided music when clicked, but other people can still hear the music of others. What’s wrong here?
enabled = false
local Parent = script.Parent
local LocalPlayer = game.Players.LocalPlayer
function onActivated()
if enabled == false then
Parent.dancepart.Position = LocalPlayer.Character.Head.Position
Parent.dancepart.SongLoop:Play()
enabled = true
while true do
wait(1)
Parent.dancepart.Position = LocalPlayer.Character.Head.Position
if enabled ~= false then
else
break
end
end
else
Parent.dancepart.SongLoop:Stop()
enabled = false
end
end
function onUnequipped()
Parent.dancepart.SongLoop:Stop()
enabled = false
end
Parent.Activated:connect(onActivated)
Parent.Unequipped:connect(onUnequipped)