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

I have an error on this script and I dont know how to fix it, how would I?

Asked by 4 years ago

So i tried to make a script where it would give me a keycard when I spawn, but it gives me an error what did i do wrong?

local players = {"CelticFury600"}
local gear = game.ServerStorage.Keycard

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
        for i = 1, #players do
            if players[i] == plr.Name then
                gear:Clone().Parent = plr:WaitForChild("Backpack")
            end
        end
    end)
0
Can you please post the error in the output? That can help me come up with a solution. Maxis_s 97 — 4y

2 answers

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
4 years ago

You forgot to add an end) for the playerAdded event. Since you haven't included it, that means that there's no end) for the event.

0
thanks CelticFury600 4 — 4y
Ad
Log in to vote
0
Answered by
Maxis_s 97
4 years ago

Alright, I tested the script, and I found the issue.

ISSUE:

You were missing an "end)" at the end of the script, ending the "PlayerAdded" function.

FIXED SCRIPT:

local players = {"CelticFury600"} --Change this to any name you want. If you want it to be any player, use "Game.Players:GetChildren()".
local gear = game.ServerStorage.Keycard

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
        for i = 1, #players do
            if players[i] == plr.Name then
                gear:Clone().Parent = plr:WaitForChild("Backpack")
            end
        end
    end)
end)

Hope this helped!

-Maxis_s

0
thanks CelticFury600 4 — 4y

Answer this question