Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
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.

0
Thanks! After fixing the errors, your script worked. spyclub65 20 — 10y
0
Lol, i keep noticing things that i did wrong :/ and np for helping you fix it :D lomo0987 250 — 10y
Ad

Answer this question