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

A script that only lets certain people spawn with tools?

Asked by 8 years ago

Hi, I'm a novice in scripting, and I am in need of help qq

Right now I am trying to create a script that would only allow certain players in the said script to spawn with these set of tools, so far this is what I got:

if game.Players.LocalPlayer.Name == "kevincatssing" then
    game.ServerStorage:GetChildren()
    for i, v in pairs(x) do
    v:Clone().Parent = game.Players["kevincatssing"].Backpack
end
end

I am planning to place the script in StarterGui

Please aid qq

1 answer

Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
8 years ago

I'm assuming that you are using a LocalScript, because you are accessing the LocalPlayer. The first Thing I see that is Incorrect is that you are accessing the ServerStorage through a localscript, and a localscript can Never access the ServerStorage, use the ReplicatedStorage instead, you also didn't define what x is on line 03, Now lets fix your script.

admin={"kevincatssing"}

game.Players.ChildAdded:connect(function(player) -- I'm using the ChildAdded instead of PlayerAdded, because PlayerAdded doesn't work with a localscript
    if player.Name==admin[1] then
        local storage=game.ReplicatedStorage:GetChildren()
        for _,value in pairs(storage) do
            if value:IsA("Tool")  or value:IsA("HopperBin") then -- use the or
                value:Clone().Parent=player:FindFirstChild("Backpack")
            end
        end
    end
end)
0
you are comparing the player's "name" to table "admin" ImageLabel 1541 — 8y
0
fixed. woodengop 1134 — 8y
0
Alright, I will try this now, thank you :D and for multiple 'admin', I just have to {"Name1", "Name2"}? kevincatssing 10 — 8y
0
If this helped do mind accepting Answer. Thanks! woodengop 1134 — 8y
View all comments (11 more)
0
I will :D! And, in ReplicatedStorage, there is also other things besides the tools that I am placing in there, how do I make it so that it will only clone the Tools (Which consist of HopperBin and Tool, in their ClassName) only? kevincatssing 10 — 8y
0
?? kevincatssing 10 — 8y
0
Clone tools only? woodengop 1134 — 8y
0
Yes, only the Tools, which consist of HopperBin and Tool, because there is also a few scripts in there that I don't want to copy over to the user's Backpack kevincatssing 10 — 8y
0
I edited my answer. woodengop 1134 — 8y
0
Oh, so, on line 7, I just need to add a value for HopperBin too, besides the Tool? if value:IsA("Too", "HopperBin") then?? QQ kevincatssing 10 — 8y
0
No no...I'll edit my answer. woodengop 1134 — 8y
0
Thank you so much :D kevincatssing 10 — 8y
0
np. woodengop 1134 — 8y
0
Ahh... Thanks for the downvote, and I was told that A localscript can't access a ServerStorage, People aren't always correct. woodengop 1134 — 8y
0
I'm stupid, sorry. You're right. Goulstem 8144 — 8y
Ad

Answer this question