Player touch part and song start playing doesn't work. The player must be the only one listing the music when he or she touch it, i mean like just their own not other players too only if they touch it too! Whats wrong? Am thankfull if someone can help me ;)
local sound = script.Parent.Sound game.Players.PlayerAdded:connect(function (newPlayer) repeat wait() until script.Parent.Parent.Parent:IsA("Player") script.Parent.Touched:connect(function(p) local human = game.Players:GetPlayerFromCharacter(p.Parent) if human and not sound.IsPlaying then sound:Play() end end) end)
This code confused me a bit.
PlayerAdded
event for a touch script.script.Parent
is a Part, how could script.Parent.Parent.Parent.Parent
ever be a Player?But the actual touch part of your script is fine, although you'll want to make sure the sound is inside PlayerGui.
local sound = script.Parent.Sound script.Parent.Touched:connect(function(p) local human = game.Players:GetPlayerFromCharacter(p.Parent) if human and not human:WaitForChild("PlayerGui"):FindFirstChild("Sound") then local newSound = sound:Clone() newSound.Parent = human.PlayerGui newSound:Play() end end)