So, I made a LocalScript inside of an ImageButton that takes away from a value inside of a separate GUI and clones an item from Lighting and into a the clicker's backpack, but it doesn't seem to be working. I also cannot found any errors, so I was wondering if anyone could find something that I may have overlooked or screwed up on. Thanks for your time!
local money = game.Players.LocalPlayer.PlayerGui.MoneyGui.Frame.Amount.Money.Value
local price = 5
script.Parent.MouseButton1Click:connect(function()
if money >= price then
money = money-5
local water = game.Lighting.Water:Clone()
water.Parent = game.Players.LocalPlayer.Backpack
print(game.Players.LocalPlayer.Name .. "has just bought Water!")
end
end)

7 comments
Number 2 is most important. But so is 1 :P
I greatly appreciate the time you have put into helping me out, but I still can't get this to work. How exactly were you suggesting I add "WaitForChild"s to the 1st line?
Lol, what's not working now? Did you try the code? This should work from what I can tell. I'll update my answer with some wait for childs
I have done exactly what you've told me to do, and I am at a bit of a loss. Not sure what else to do but seek more help. Thank you so much for your effort.
Yeah cool great. What's wrong with it? Are there no error messages? Does it print? Is the script disabled? But oh well. Good luck!
Script is enabled, there are no error messages, and it does not print. Anyways, I'm going to rest my brain now. Thanks again...
You're welcome