local Cost = script.Parent.Parent.Cost
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)
if player.leaderstats.Points.Value >= Cost.Value then
player.leaderstats.Points.Value -= Cost.Value
script.Parent.CanCollide = false
wait(5)
db = true
script.Parent.CanCollide = true
end
end
end
end)
When i Hit the wall or the "door" it doesnt subtract the Coins and let me go through idk whats wrong my script seems perfectly fine and no errors in output