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

How do I add/remove any weaponry from the tool inventory upon joining the game?

Asked by 10 years ago

What I would like to do is get rid of all of the tools and add a sword and a gun for my fighting game, and that's it. How do I do that?

I am not sure if the tag is correct. :l

2 answers

Log in to vote
0
Answered by
LevelKap 114
10 years ago
Player = game.Players.LocalPlayer
Backpack = Player.Backpack

for i, v, in pairs(Backpack:GetChildren()) do
    if v:IsA("Tool") then
        v:Destroy() 
        wait()
    end
end

--[[First you need to understand where tools are. Tools are in your backpack. To place a sword and gun in your inventory, you can place them directly in your backpack when testing or place the tools in the starter pack so everyone gets one when they join. To remove any other tools use a in pairs loop. Look it up on the wiki so you understand a little better. insert a LOCAL script, place this in a starter pack(or backpack to test) and paste the following code]]--

Player = game.Players.LocalPlayer Backpack = Player.Backpack

for i, v, in pairs(Backpack:GetChildren()) do if v:IsA("Tool") then v:Destroy() wait() end end

--An alternative if you know the name of the tool you want: Player = game.Players.LocalPlayer Backpack = Player.Backpack

for i, v, in pairs(Backpack:GetChildren()) do if v.Name == "whateverthetoolnameis" then v:Destroy() wait() end end

--Thumbs up would be greatly appreciated :DD

Ad
Log in to vote
0
Answered by 10 years ago

LevelKap,

I understand that this isn't an answer, but can you put it into code form? I can't run (test) the Local Script.

Answer this question