price = 50 local texthandler = coroutine.create(function() while wait() do script.Parent.Text = "UPGRADE BUILDING [Level: "..script.Parent.Parent.Parent.Selected.Value.Level.Value"]" end end) script.Parent.MouseButton1Down:connect(function() coroutine.resume(texthandler) print("Test") local level = script.Parent.Parent.Parent.Selected.Value.Level if script.Parent.Parent.Parent.Parent.Parent.Gold.Value >= price then script.Parent.Parent.Parent.Parent.Parent.Gold.Value = script.Parent.Parent.Parent.Parent.Parent.Gold.Value-price price = price*2 script.Parent.Parent.Parent.Selected.Value.Level.Value = script.Parent.Parent.Parent.Selected.Value.Level.Value+1 end end)
I've been making this script to upgrade a building by clicking on a TextButton. I've set several breakpoints and prints(), but it seems to not even start working. The script is enabled and there's no mistake that I can find. So what's wrong? Here's the Explorer: http://prntscr.com/9jucl3
You will need to change the Script to a LocalScript
Also on line 4,
script.Parent.Text = "UPGRADE BUILDING [Level: "..script.Parent.Parent.Parent.Selected.Value.Level.Value"]"
Should be...
script.Parent.Text = "UPGRADE BUILDING [Level: "..script.Parent.Parent.Parent.Selected.Value.Level.Value.."]"
I also wouldn't recommend having that loop (texthandler) without some way to break it, unless you want it to go on forever? It could lag up the client a bit.