So I made this script for a cookie clicker type game, but the problem is that the cookies are going into the negative and the cookies are not subtracting properly. Sometimes the total cookies are more or equal to the cost, sometimes it allows to purchase at way lower
local Buy = script.Parent
local Count = script.Parent.ClickerCount
local TotalCookies = script.Parent.Parent.TotalCookies
local Cost = script.Parent.ClickerCost
Buy.MouseButton1Click:Connect(function()
if TotalCookies.Text >= Cost.Text then
workspace.Purchased.Playing = true
TotalCookies.Text = TotalCookies.Text - Cost.Text
Count.Text = Count.Text + 1
Cost.Text = Cost.Text + Cost.Text - 20
else
workspace.Error.Playing = true
end
end)
It's a super basic project i'm working on for fun, but I really need to get past this part. Help is greatly appreciated.

3 comments
I don't have IntValues, do I need to use them or? Also thanks for replying
U should use NumberValues
Thanks I will try that!