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

How can I make it so when "Username" joins the game Audio plays?

How can you make any Audio play when a certain person joins a game?

4 comments

0

Or you could use user ids because if that player changes their name it wont count anymore, but i still recommend Geobloxia's comment

0

Entity is right. User ids are better

0

Alright, thank you.

0

Put in the title so people know it is solved.

2 answers

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == "CertainPlayerName" then
		script.Sound:Play()
	end
end)

or

local certainid =  -- Put player's userid
game.Players.PlayerAdded:Connect(function(player)
	if player.UserId == certainid then
		script.Sound:Play()
	end
end)

or

local certainplayers = {"Certainplayer1", "Certainplayer2"}
game.Players.PlayerAdded:Connect(function(player)
	for i, v in pairs(certainplayers) do
		if player.Name == v then
			script.Sound:Play()
		end
	end
end)

1 comment

0

The last one is for more than one certain player and is the most efficient code for this objective.

make a script to fire when a player is added and to find what player it is

game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name == ("YourName") then
		--//make audio play for example
		game.Workspace.Audio:Play()
	end
end)

1 comment

0

The only problem with this is the parenthesis, it should be only a string: if plr.Name == "YourName" then

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