Okay so, when I add the the line of math to substract the money, it substracts the money, but the it’s like the rest of the code stops working, it doesn’t change the transparency or the collider… those will work without the line thought, what am I doing wrong?
My script:
local RC = 100000 --Required Coins to unlock
local chill = false --debounce
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player.leaderstats.Coins.Value >= RC then --Enter your own currency name instead of "Coins"
if not chill then
chill = true
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 100000 --THIS LINE
script.Parent.Transparency = 1 --Full transparency
script.Parent.SurfaceGui.TextLabel.Visible = false --hide the textlabel, must be named TextLabel
script.Parent.CanCollide = false
if player.leaderstats.Coins.Value <= RC then
script.Parent.Transparency = 0 --No transparency
script.Parent.SurfaceGui.TextLabel.Visible = true --Show the textlabel, must be named TextLabel
script.Parent.CanCollide = true
wait(2)-- Spam protector
chill = false -- Spam protector
end
end
end
end
end)