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

How do i insert a sound inside a player?

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)

``

3 answers

✓ Accepted answer

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)

1 comment

0

lol its been 17 days but ty!

Sorry i was a noob at scripting here, i have fixed it :D

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)

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