Why this code don't work, im clicking upgrade button but it doing nothing

also didn’t and also nothing in the output

Could you kindly provide a video?

changed 22 to if NumberOfUpgrades == 0 and Money.Value >= 5 then but still nothing

Could you add a print statement to see if it does anything, also remove game:WaitForChild(“StarterGui”), you don’t need it.

where? i need to add print statement?

Inside of the if statement in the function.

image
image

Then that means there’s something wrong with that if statement.

but what is wrong in it i dont understand

Remove the NumberOfUpgrades check, also you’re checking for the value of “Money” when it’s not updated everytime, so of course it won’t do anything.

from seeing this, assuming NumberOfUpgrades are a value???

if it does then you forgot the .Value at the if NumbersOfUpgrades == 0 when comparing cuz it’s assigning to Instance instead of actual properties of it.

Whenever you want to compare/change/check Values in that Instance Class, always have the .Value at the end, you can’t just directly edit/compare them like the normal values (created as variable) as it’s in a Instance Class form.

e.g

local num_of_upgrade = 5 --normal datatypes which you can edit it directly since there's no properties 
num_of_upgrade = 1 --can be set anytime

local num_val = script.blahblahwherever
if num_val == 0 then --client or server sees this as Instance instead of values as there's properties 
end


local num_val = script.blahblahwherever
if num_val.Value == 0 then --when adding .Value, you're now editing it by using the script as it's now assigned to the properties.
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.