What I am trying to achieve is, when someone joins there will be a sound inside their character inside workspace this is what i have done so far.But it doesn't work,I don't get anything from the output
local PlayerService = game:GetService("Players") local PlayerPerson = PlayerService:GetPlayerFromCharacter() local PlayerName = PlayerService.LocalPlayer.Name function MusicNeeded() print("Music is being added to "..PlayerName.."!") wait(3) local MusicBeingAdded = Instance.new("Sound") MusicBeingAdded.Parent = PlayerPerson end PlayerService.PlayerAdded:Connect(MusicNeeded)
``
Why not simply use the "player" paramater from the PlayerAdded
event, i'm not sure about what's wrong with your script though. Try this out and see if it works.
function MusicNeeded(plr) print("Music is being added to "..plr.Name.."!") wait(3) local MusicBeingAdded = Instance.new("Sound") MusicBeingAdded.Parent = plr end PlayerService.PlayerAdded:Connect(MusicNeeded)
Also putting it the player is kind of useless, since it will not act as a 3D object. So you may wanna put it inside the character
function MusicNeeded(plr) print("Music is being added to "..plr.Name.."!") wait(3) local MusicBeingAdded = Instance.new("Sound") MusicBeingAdded.Parent = plr.Character end PlayerService.PlayerAdded:Connect(MusicNeeded)
Why are you putting the sound inside of the player in Players rather than putting it into the character?
game.Players.PlayerAdded:Connect(function(player) -- When a player joins player.CharacterAdded:Connect(function(char)) -- When the character loads local sound = Instance.new("Sound", char) -- Create the sound end) end)