I have a script, that requires sufficient credit in order to pass through a door. But it should only charge once:
script.Parent.Touched:connect(function(player) --Door gets touched
humanoid = player.Parent:FindFirstChild("Humanoid") --If it's the player that touched the door
if humanoid ~= nil then
person = game.Players:FindFirstChild(player.Parent.Name)
touched = script.Parent:FindFirstChild(player.Parent.Name)
if person ~= nil and touched == nil then
person.leaderstats.Admins.Value = person.leaderstats.Admins.Value - 1 --Decreases the credits
a = Instance.new("StringValue", script.Parent)
a.Name = player.Parent.Name
script.Parent.CanCollide = false
wait(2)
script.Parent.CanCollide = true
elseif touched ~= nil then
script.Parent.CanCollide = false
wait(2)
script.Parent.CanCollide = true
else humanoid.Health = 0
end
end
end

1 comment
Just test it in game, if it doesn't work, use F9 and look at server console (Output)