I'm trying to make a game where the point of the gameplay is to collect batteries (to power up a machine), the problem is my script only works once, as in once someone collects it, no one can collect it anymore. Is there any way I can improve this script so that multiple people can collect it also?
local db = true
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if db == true then
db = false
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Batteries.Value = player.leaderstats.Batteries.Value + 1
wait(5)
local db = true
end
end
end)
thanks

1 comment
I tried it and it still increases the value even after you grabbed it