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

How can I change a TextBox's text when a player gets enough points?

This script is located in "StarterGui" Here is what I tried:

local fgui = script.Parent:WaitForChild("rockettips")
local tgui = fgui:WaitForChild("TextBox")

local stats = script.Parent.Parent:WaitForChild("leaderstats")
local point = stats:WaitForChild("Points")
local points = point.Value

repeat
	wait(0.1)
until points > 9
tgui.Text = "Wall Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 20 points"
repeat
	wait(0.1)
until points > 19
tgui.Text = "Balloon Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 35 points"
repeat
	wait(0.1)
until points > 34
tgui.Text = "Bomb Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 50 points"
repeat
	wait(0.1)
until points > 50
tgui.Text = "Fast Rocket Earned!"
wait(3)
tgui.Text = "All Rockets Earned!"

1 answer

✓ Accepted answer
local fgui = script.Parent:WaitForChild("rockettips")
local tgui = fgui:WaitForChild("TextBox")

local stats = script.Parent.Parent:WaitForChild("leaderstats")
local point = stats:WaitForChild("Points")

local rocket = 0

point.Changed:connect(fucntion(rocket)
if point.Value > 9 and rocket == 0 then
rocket = 1
tgui.Text = "Wall Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 20 points"

elseif point.Value > 19 and rocket == 1 then
rocket = 2
tgui.Text = "Balloon Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 35 points"

elseif point.Value > 34 and rocket == 2 then
rocket = 3
tgui.Text = "Bomb Rocket Earned!"
wait(3)
tgui.Text = "Next Rocket at 50 points"

elseif point.Value > 50 and rocket == 3 then
rocket = 4
tgui.Text = "Fast Rocket Earned!"
wait(3)
tgui.Text = "All Rockets Earned!"
end)

-- I keep spotting little things I missed. :/ so the edits are them.

What I did was change it so every time the leaderstat 'Points' get changed it checks to see if it is the correct value. I also set up a test to see if they have already claimed it (Hence the local rocket).

If this doesn't work please tell me and I will try to fix whatever is broken.

2 comments

0

Thanks! After fixing the errors, your script worked.

0

Lol, i keep noticing things that i did wrong :/ and np for helping you fix it :D

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