Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script isn't counting properly?

Asked by 4 years ago
Edited 4 years ago

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.

0
I don't have IntValues, do I need to use them or? Also thanks for replying ElongatedMongoose 138 — 4y
0
U should use NumberValues ArCeMo6 -1 — 4y
0
Thanks I will try that! ElongatedMongoose 138 — 4y

Answer this question