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

The Label doesn't display the Costs of the Rebirth?

Asked by 4 years ago

So I want the label to show how much the Rebirth Costs but it only displays 0 no matter how much rebirths the player has. - The Player starts with 1 Rebirth - Theres nothing wrong with the Locals - Its not a LocalScript

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local dinbux = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.DinBux
local rebirths = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.Rebirths
local label = script.Parent

while true do
    label.Text = "Rebirth Costs: "..(rebirths.Value * 1000000).." DB"
end

Thanks in Advance! - DindinYT37

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The problem is that the script doesn't renew the variables, cuz the script just get them once. Put the variables in the while wait so it renews the variables each time the script runs the loop:

while true () do
    local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
    local dinbux = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.DinBux
    local rebirths = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.Rebirths
    local label = script.Parent
    label.Text = "Rebirth Costs: "..(rebirths.Value * 1000000).." DB"
end

Also, you need a waiting time. I added a () at the while wait. We are not obligated to put numbers in that (). Without numbers in that (), the script will just redo the loop each time the previous loop has finished.

Hope this helped!

Ad
Log in to vote
1
Answered by 4 years ago

Assuming all of your variables are correct, you need to fix your infinite loop changing label's text. To fix this, you can add a wait(time) within the loop.

Here is the script:

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local dinbux = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.DinBux
local rebirths = script.Parent.Parent.Parent.Parent.Parent.Parent.leaderstats.Rebirths
local label = script.Parent

while true do
    label.Text = "Rebirth Costs: "..(rebirths.Value * 1000000).." DB"
    wait(1)
end

Answer this question