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

how do i add like a sword to my starter pack to where only certain players can get it?

Asked by 8 years ago

how do i add like a sword to my starter pack to where only certain players can get it

2 answers

Log in to vote
2
Answered by 8 years ago

A PlayerAdded and CharacterAdded events are needed to do this. Script

game.Players.PlayerAdded:connect(function(plr) -- playeradded event identifying the player that joined as "plr"
    plr.CharacterAdded:connect(function(char) -- characteradded event, identifying the plr's character that respawned as "char"
    if plr.Name == "NameHere" then -- Change "NameHere" to the player that has the permission to have the tool.
           local tool = game.ServerStorage.Tool:Clone() -- cloning the tool from serverstorage, change this to your parenting
           local backpack = plr:findFirstChild("Backpack") -- getting the player's backpack
       if backpack then -- checking if the backpack exists to prevent possible errors(not necessary)
               tool.Parent = backpack -- parenting it to their backpack.
            end
        end
    end)
end)

Full Script:

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if plr.Name == "NameHere" then
            local tool = game.ServerStorage.Tool:Clone()
            local backpack = plr:findFirstChild("Backpack")
            if backpack then
                tool.Parent = backpack
            end
        end
    end)
end)

Hope it helped!

0
where do i put that just in work space? ags5321 0 — 8y
0
im confused on line 4 ags5321 0 — 8y
0
Put the tool under ServerStorage, and name it "Tool" AbsoluteAxiom 175 — 8y
0
I made a mistake on line 4 because I was typing really fast and was in a hurry, but I just fixed it. AbsoluteAxiom 175 — 8y
View all comments (4 more)
0
Ok where do I but the tool name ags5321 0 — 8y
0
Ok where do I but the tool name ags5321 0 — 8y
0
You replace "Tool" on line 4 with the tool name. AbsoluteAxiom 175 — 8y
0
Ok where do I but the tool name ags5321 0 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

game.Players.PlayerAdded:connect(function(plr) -- playeradded event identifying the player that joined as "plr" plr.CharacterAdded:connect(function(char) -- characteradded event, identifying the plr's character that respawned as "char" if plr.Name == "ags5321" then -- Change "NameHere" to the player that has the permission to have the tool. local tool = game.ServerStorage:Clone("Card1") -- cloning the tool from serverstorage, change this to your parenting local backpack = plr:findFirstChild("Backpack") -- getting the player's backpack if backpack then -- checking if the backpack exists to prevent possible errors(not necessary) tool.Parent = backpack -- parenting it to their backpack. end end end) end)

is that it

Answer this question