Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the TextButton in a ScrollingFrame working?

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

1 answer

✓ Accepted answer

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.

3 comments

1

I would personally connect that function to the Changed event of the Level value.

0

Thanks a lot. I only had to change it to a LocalScript.

0

No problem

This discussion is preserved as it was. New answers, comments, and votes are closed.