So I was trying to make this Leaderstat Door, but for some reason, it's not working. It worked once in a different Place, but it stopped working. Can someone tell me what I did wrong or help me fix it? Thanks.
(script in part)
local required_cash = 1000
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_cash then
if db then
db = false
script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
wait(3)
script.Parent.CanCollide = true
script.Parent.Transparency = 0
db = true
end
end
end
end)
(local script)
local required = 1000
local player = game.Players.LocalPlayer
local stat = player:WaitForChild("leaderstats"):WaitForChild("Cash")
stat.Changed:connect(function()
if stat.Value >= required then
script.Parent.TextLabel.Text = "Door Unlocked!"
end
end)
(my currency system)
game.Players.PlayerAdded:Connect(function(player)
local fold = Instance.new("Folder", player)
fold.Name = "leaderstats"
local stat = Instance.new("IntValue", fold)
stat.Name = "Cash"
end)
if someone could please help me, i'd greatly appreciate it thank you once again

2 comments
thank you for answering, but i found out the problem to be my cash script. Thank you once again though!
its good yw