I'm trying to make this script work, to take away 100 "money", and make the textbox say "confirmed purchase", if they have more or equal, but if they have less, it says "Error!", and doesn't do anything. It dosen't work, and I need help to fix it. I cant find anything wrong, and nothing shows up in output.
Code :
local player = game.Players.LocalPlayer
function onClicked()
if player:FindFirstChild("Money").Value >= 100 then ---------seeing if the money is greater than or equal to 100
script.Parent.Text = "Confirmed purchase!" ------ telling the money has been confirmed
player:FindFirstChild("Money").Value = player:FindFirstChild("Money").Value-100 ---- subtracting 100
if player:FindFirstChild("Money").Value < 100 then ------- if the money is less than 100
script.Parent.Text = "Error!" ------- saying error because not enough money
wait(3) ---- waiting so the player can see it
return ---- returning the script to the way it was before
end
end
end

4 comments
Is this a localscript?
Yes.
Is this the entire script? You don't ever connect
onClickedto anything.Oh... thanks, I'll play around with this.