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

Why doesn't this PlayerAdded script work?

Asked by
JJ_B 250 Moderation Voter
8 years ago

I made a script that gives me or the solo test "Player" a tool when they join a game. However, it doesn't work, and the output doesn't tell me anything. Here is the script.

local Players = game:GetService("Players")

function onPlayerAdded(player)
    local l = game.ServerStorage.LASM:Clone()
    if player.Name == "Wizardel" or player.Name == "Player" then
        l.Parent = player.Backpack
    end
end

Players.PlayerAdded:connect(onPlayerAdded)

for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end


I need the

for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end

bit so that it works in Solo Test mode. Can anybody help?

1 answer

Log in to vote
0
Answered by 8 years ago

Usually, the player is called "Player1" and "Player2" and so on... Try changing the string to that.

0
Except it's not, It's called "Player" whenever I test it. Also, it doesn't work for me in online mode. JJ_B 250 — 8y
Ad

Answer this question