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

How to give a specific person a special tool? ANSWERED :D

Asked by 10 years ago

Since yesterday thanks to some awesome scripters, they taught me what does for _, in pairs mean and next. So I want to give some people, my friends, a special tool, every time they spawn into my game. I know that it comes from the Lighting, you clone it, and it goes into their Backpack. However this happens to me in everything. I know how it works, the sequence, but when I script, I sorta crack xD. So this is what I have done so far :o

function DoThis()
admins = {"offbeatpizzalives123", "NdetanBill"}
for _, v in pairs(game.Players:GetPlayers()) do
    if v == admins then

    end
end

I know that It's hardly done, I don't even have the connection line. And the 'if v == admins then' is not done. This is what I don't understand. How will it clone it into the Backpack? Will it give it to a random person? The for loop is going to read the Table. It's going to check the all the Players. If it's not this player, go to the other one until you find it. I know it's my second question on my second day. I know I'm a tad bit- well, pretty annoying. I just have a pal who told me it took him two months to learn. But he's not that good. And he's telling me it shouldn't take long. And that's what I'm afraid of. I want to take it my pace. But I also don't want to finish learning Lua by the next Century. Answer this Please

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

You were almost on the right track.

admins = {"offbeatpizzalives123", "ndetannill"} -- The Table (Not Case Sensitive)
tool = game.ServerStorage["Tool name here"] -- Path that leads to the tool

game.Players.PlayerAdded:connect(function(p) -- PlayerAdded event
    for _,admin in pairs(admin) do -- Goes through the table
        if p.Name:lower() == admin:lower() then -- Checks if the Name is in the table
            repeat wait() until p.Backpack -- Waits until there is a Backpack
            tool:clone().Parent = p.Backpack -- Clones it to the Backpack
            tool:clone().Parent = p.StarterGear -- Clones it to the StarterGear
        end
    end
end)
0
>:O Why didn't I think of that qq offbeatpizzalives123 105 — 10y
0
You had it on the tip of your tongue. Nice attempt, though. Shawnyg 4330 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago
local admins = {"name here", "name here")
game.Players.PlayerAdded:connect(function(player)
    if player.Name == admins then
    local toolplace = player.Backpack
    local newtool = script.tool:Clone()
    newtool.Parent = toolplace
    end
end)

this script would probably work better. basically, it checks if the new players name is equivalent to admins. If it is, it takes the tool from the inside of the script, and puts it in the players backpack. This im not sure of, but you can try this to,

local admins = {"name here", "name here")
game.Players.PlayerAdded:connect(function(player)
    if player.Name == admins then
    local toolplace = player.Backpack
    local newtool = script.tool:Clone()
    newtool.Parent = toolplace
    local permtool = newtool:Clone()
    permtool.Parent = Player.StarterPack
    end
end)

I think that puts it in the players personal starterpack, becuase i know that is a file in the player in players, but im pretty sure the player added function only lets it be added once. so im very sure the second one allows it to work everytime.

Answer this question