THIS IS A REPOST, BECAUSE I GOT A CONFUSING ANSWER ON THE FIRST ONE LIKE 3 DAYS AGO
title might be confusing but, i'm making a button that gives you a weapon on a certain level, but to avoid taking up room in the backpack, i need it to delete the previous gear, or all gears before placing the new gear down, the thing i really need help with is how to get all the tools in the players backpack, i don't really know how to define that.
Here is my current Script
Points = 10
Stat = "Points"
Give = script.Parent
Backup = Give:Clone()
function onTouched(hit)
if hit.Parent.Humanoid~= nil then
local Plr = game.Players:findFirstChild(hit.Parent.Name)
if Plr ~= nil then
local StatLocal = Plr.leaderstats:findFirstChild(Stat)
if StatLocal ~= nil then
if StatLocal.Value >= Points then
local Check = Plr.StarterGear:findFirstChild(script.Parent.Name)
if Check == nil then
StatLocal.Value = StatLocal.Value - Points
local W1 = Backup:Clone()
local W2 = Backup:Clone()
W1.Parent = Plr.Backpack
W2.Parent = Plr.StarterGear
end
end
end
end
end
end
script.Parent.Parent.Touched:connect(onTouched)
this script does the job of putting the weapon in your backpack AND Starterpack, so if you die, you'll get the weapon back
Hey SteamDemand, Please don't make this extremely confusing :C

1 comment
thank you