Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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! :)

8 comments

0

A server script, if that's what you mean.

0

im so lost

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...

0

nothing i have the scipt in workspace and card1 in serverstorage

0

I just want it so I can get the card when I enter the game just me and no one else

0

I just want it so I can get the card when I enter the game just me and no one else

0

@saenae You're missing the "name" on the table..

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.