Im trying to make a door you can buy but it is a 1 time purchase and when i walk up to the door to buy it it keeps draining my cash and is not 1 time or unlocked for the rest of the game my current script
local required_points = 0
local db = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Cash.Value >= required_points then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - required_points
if db then
db = false
script.Parent.Transparency = 1
script.Parent.CanCollide = false
wait(1)
script.Parent.Transparency = .75
script.Parent.CanCollide = true
db = true
end
else
player.Character.Humanoid.Health = 0
end
end
end)
