Hello, I create a script to rebirth on my game and once the game starts, this error arises and I can't solve it. Rebirths is not a valid member of Folder (Line 8) could someone please help me?

the code :

local replicatedStorage = game:GetService("ReplicatedStorage")
local startRebirthAmount = 1000

local player = game.Players.LocalPlayer
local desc = script.Parent.UpFrame.desc
local rebirthButton = script.Parent.GetFrame.TextButton
local rebirthButtonDesc = script.Parent.GetFrame.TextLabel
local rebirths = player:WaitForChild("leaderstats").Rebirths

desc.Text = "You need "..math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ???? To rebirth!  When you get the first Rebirth you get double the Aura. Vous avez besoin de "..math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ???? pour renaître! Lorsque vous obtenez la première renaissance, vous obtenez le double d'Aura par click."
rebirthButtonDesc.Text = math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ????"

rebirthButton.MouseButton1Click:Connect(function()
	local result = replicatedStorage.Remotes.Rebirth:InvokeServer()
	
	if result == true then
		rebirthButton.text = "Succefully Rebirthed"
		wait(1)
		rebirthButton.Text = "Rebirth"
	elseif result == "NotEnoughAura" then	
		rebirthButton.text = "Not aura enough!"
		wait(1)
		rebirthButton.Text = "Rebirth"
	end
end)

rebirths:GetPropertyChangedSignal("Value"):Connect(function()
	desc.Text = "You need "..math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ???? To rebirth!  When you get the first Rebirth you get double the Aura. Vous avez besoin de "..math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ???? pour renaître! Lorsque vous obtenez la première renaissance, vous obtenez le double d'Aura par click."
	rebirthButtonDesc.Text = math.floor((startRebirthAmount + (rebirths.Value) * math.sqrt(50000000))).." ????"

end)

2 comments

0

I guess the folder hasn't been created yet, so you could do. player:WaitForChild("leaderstats"):WaitForChild("Rebirths")

0

it's work, thank !!