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

2 answers

Log in to vote
1
Answered by
Geobloxia 251 Moderation Voter
4 years ago
Edited 4 years ago
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)
0
The last one is for more than one certain player and is the most efficient code for this objective. Geobloxia 251 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
0
The only problem with this is the parenthesis, it should be only a string: if plr.Name == "YourName" then User#32819 0 — 4y

Answer this question