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

how would i allow Card1 to be in a starter pack and go to only certain players?

Asked by 9 years ago
game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if plr.Name == "AGS5321" then
            local Card1 = game.ServerStorage.Card1:Clone()
            local backpack = plr:findFirstChild("Backpack")
            if backpack then
                Card1.Parent = backpack
            end
        end
    end)
end)

only want card1 to go to certain players but idk what to do from here

1 answer

Log in to vote
0
Answered by
saenae 318 Moderation Voter
9 years ago

You'll probably want to make a table out of the people you'd like to be able to use 'Card1', like so;

Card1People = {"ags531", "saenae", "Telamon"} -- Table of people who can use Card1
game.Players.PlayerAdded:connect(function(newPlayer)
    newPlayer.CharacterAdded:connect(function(Char)
        for i, v in pairs(Card1People) do -- Checking if newPlayer's in the table
            if newPlayer.Name == v then
                local Card1 = game.ServerStorage.Card1:Clone()
                local backpack = plr:findFirstChild("Backpack")
                if backpack then
                    Card1.Parent = backpack
                end
            break -- Stopping the loop if he/she gets the card
            end
        end
    end)
end)

Hope this helps! :)

0
A server script, if that's what you mean. saenae 318 — 9y
0
im so lost ags5321 0 — 9y
0
Hm. I'm guessing you've got Card1 in your ServerStorage already, so you can just put this code in a regular script and insert that into the workspace. It'll work whenever anyone joins the server. Not sure if that clears anything up... saenae 318 — 9y
0
nothing i have the scipt in workspace and card1 in serverstorage ags5321 0 — 9y
View all comments (4 more)
0
I just want it so I can get the card when I enter the game just me and no one else ags5321 0 — 9y
0
I just want it so I can get the card when I enter the game just me and no one else ags5321 0 — 9y
0
@saenae You're missing the "name" on the table.. Nickoakz 231 — 9y
0
@Nick, I fixed it. Thanks for pointing that out to me! @Ags, just erase all of the names from the table except your own then. saenae 318 — 9y
Ad

Answer this question