Can't Change Text For Rebirth Amount

Because I don’t Show how many “Super” Rebirths a player has on the leaderstat I have a text label that is meant to show how many rebirths the player has. But the script is not working and is giving me a warn because It can’t change the text label.

local SuperRebirthTextV = game.Players.LocalPlayer.PlayerGui.RebirthGui.RebirthFrame.SuperRebirthText
local SuperRebirthAmount = game.Players.LocalPlayer.notleader.SuperRebLevelzz.Value


if SuperRebirthAmount == 1 then
	SuperRebirthTextV.Text = "You Have 1 Super Rebirth"
else
	
	warn("Error while Changing the Super Rebirth Text")
	end

if SuperRebirthAmount > 1 then
	SuperRebirthTextV.Text = "You have " .. SuperRebirthAmount .. " Super Rebirths"
else
	warn("Error while Changing the Multiple Super Rebirth Text")
end

It warns me for both…

Thanks for Helping!

What happens if you print the amount in SuperRebirthAmount, what does it print out?

2 Likes

It print how many rebirths I have. Which is 0

I change it using console and the text still doesn’t work

Well, that makes sense. The first line:

if SuperRebirthAmount == 1 then
	SuperRebirthTextV.Text = "You Have 1 Super Rebirth"
else
warn("Error while Changing the Super Rebirth Text")
	end

will definitely do the warn since 0 is not equal to 1, and you said that 0 is the amount of super rebirths you have.

Secondly, this line:

if SuperRebirthAmount > 1 then
	SuperRebirthTextV.Text = "You have " .. SuperRebirthAmount .. " Super Rebirths"
else
	warn("Error while Changing the Multiple Super Rebirth Text")
end

is also going to warn as 0 is not greater than 1. A fix for this is to make a new line:

if SuperRebirthAmount < 1 then
	SuperRebirthTextV.Text = "You have 0 Super Rebirths"
else
	warn("Error while Changing the Multiple Super Rebirth Text")
end

This one should change the text.

You can’t set the value to a variable

local SuperRebirthAmount = game.Players.LocalPlayer.notleader.SuperRebLevelzz.Value

This sets the SuperRebirthAmount to the value and it won’t change. You need to do something like this

local SuperRebirthAmount = game.Players.LocalPlayer.notleader.SuperRebLevelzz

And use

SuperRebirthAmount.Value

where ever you want to get the value

EDIT: @AAD232007 is also correct. Your not checking if the user has 0 rebirths. Personally I would do something like this

if SuperRebirthAmount.Value == 1 then
	SuperRebirthTextV.Text = "You have 1 Super Rebirth"
else
	SuperRebirthTextV.Text = "You have " .. SuperRebirthAmount.Value .. " Super Rebirths"
end

Thats the same thing as what I did except Value. I tried many tests but it didn’t work. It only worked for if somebody has 0 rebirths then it would change text like how @AAD232007 did it.

If you use the way you did it

local SuperRebirthAmount = game.Players.LocalPlayer.notleader.SuperRebLevelzz.Value

then SuperRebirthAmount will always be equal to that value even if the IntValue changes because your setting it to the value at that time. If you use the way I told you then it gets the new value inside the IntValue every time you call it so it will always update. I’m not sure if it makes any sense but it’s kind of hard to explain

Everything works now!

30charrr