So you step on a part then you get the tool "Jar" added to your inventory. The limit of jars supposed to be 5 and stop giving you jars when that happens. So I create a table by getting the humanoids children named "Jar". The table is instantly at 27 when I step on the part so that is what my problem definitely is, just I do not know how to fix it. If any idea's, comment and if you provide a solution that works I will accept your answer and add to your reputation.
local object = script.Parent
local debounce = false
function givePlayerJar(hit)
if hit.Parent:FindFirstChild("Humanoid")then
if debounce == false then
debounce = true
local jarCheck = hit.Parent:GetChildren("Jar")
local jarNum = table.getn(jarCheck)
print(jarNum)
if jarNum ~= 6 then
local cloneJar = game.ReplicatedStorage.Jar:Clone()
cloneJar.Parent = hit.Parent
wait(1)
debounce = false
end
end
end
end
object.Touched:Connect(givePlayerJar)

1 comment
local jarCheck = hit.Parent:GetChildren("Jar")