Button not deducting coins when having over 400, button value is 250


local Button1 = script.Parent
Button1Value = 250

Button1.Touched:Connect(function(touched)
local plr = game.Players:GetPlayerFromCharacter(touched.Parent)
local Num1 = workspace.Num1
if plr and plr.leaderstats.Coins.Value >= 200 then
Button1:Destroy()

	Num1.Part.Transparency = 0
	print("You can afford it")


	local TotalScore = plr.leaderstats.Coins.Value - Button1Value
	print(TotalScore)
	plr.leaderstats.Coins.Value = TotalScore

else
	Button1.BrickColor = BrickColor.Random()
	print("You cannot afford that")
end

end)



script.Parent.MouseButton1Click:Connect(function(coins)
local plr = game.Players.LocalPlayer

local coins = plr:WaitForChild("leaderstats"):WaitForChild("Coins")

coins.Value = coins.Value+1

end)
image

2 Likes

(why are you using light mode)

is there anything on the output?

image
here in line two you should write

local Button1Value = 250

fix this and it should work, sincerely,
oski3d1

1 Like

why not and no there is not anything

I see now. You are adding values through a localscript. The server does not detect client-side changes. Consider using remoteevents and fire it through the server