Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Slviq 0
5 years ago

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

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 EllaTheFloofyFox 106 — 5y
0
Entity is right. User ids are better Geobloxia 251 — 5y
0
Alright, thank you. Slviq 0 — 5y
0
Put <SOLVED> in the title so people know it is solved. Geobloxia 251 — 5y

2 answers

Log in to vote
1
Answered by
Geobloxia 251 Moderation Voter
5 years ago
Edited 5 years ago
1game.Players.PlayerAdded:Connect(function(player)
2    if player.Name == "CertainPlayerName" then
3        script.Sound:Play()
4    end
5end)

or

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

or

1local certainplayers = {"Certainplayer1", "Certainplayer2"}
2game.Players.PlayerAdded:Connect(function(player)
3    for i, v in pairs(certainplayers) do
4        if player.Name == v then
5            script.Sound:Play()
6        end
7    end
8end)
0
The last one is for more than one certain player and is the most efficient code for this objective. Geobloxia 251 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

1game.Players.PlayerAdded:Connect(function(plr)
2    if plr.Name == ("YourName") then
3        --//make audio play for example
4        game.Workspace.Audio:Play()
5    end
6end)
0
The only problem with this is the parenthesis, it should be only a string: if plr.Name == "YourName" then User#32819 0 — 5y

Answer this question