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

Only add 1 item into backpack?

Asked by
lushguy 13
5 years ago

This script is used to add an item to a players backpack once they are on a certain team but when ever I test it it always adds 4 items instead of only 1.


local Tools = { ["Assassins"] = game.ServerStorage.Tag, } while true do wait(5) game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) plr.Changed:connect(function() if plr.Team == game.Teams.Assassins then Tools.Assassins:Clone().Parent = plr:WaitForChild("Backpack") end end) end) end) end
0
check the backpack for the item before adding it, if its there return nothing DinozCreates 1070 — 5y
0
What should i put to check i'm stuck on that part lushguy 13 — 5y
0
it might work fine if you just get rid of the while loop. i dont know why its there. DinozCreates 1070 — 5y
0
yeah you don't need the while loop awesomeipod 607 — 5y

1 answer

Log in to vote
0
Answered by
lushguy 13
5 years ago
Edited 5 years ago

Ok so I removed the while loop and I tried to add a check but it still adds 2 items to the players that join the team


local Tools = { ["Assassins"] = game.ServerStorage.Tag, } wait(5) game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local NumItems = plr.Backpack:GetChildren() plr.Changed:connect(function() if NumItems == 1 then return end if plr.Team == game.Teams.Assassins and #NumItems == 0 then Tools.Assassins:Clone().Parent = plr:WaitForChild("Backpack") print(#NumItems) end end) end) end)
Ad

Answer this question