Rebirth table not being recoginzed?

I am attempting to make a rebirth UI show the current and next level rebirth stats but for some reason the table is nil when I try to set it to a variable. the output even prints out how the newRebirthLevel is “1” and how “rebirthtable[1]” is not nil but when I set the value to a variable it states it is nil and I cant access the multiplier value.

CODE

local Rebirth = {}

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local PlayerGui = Player:WaitForChild("PlayerGui")
local RebirthUI = PlayerGui:WaitForChild("RebirthUI")

local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Events = ReplicatedStorage:WaitForChild("Remotes").Events
local Functions = ReplicatedStorage:WaitForChild("Remotes").Functions

function Rebirth:Tween(state, waitUntilFinished)
    local TweenPosition 

    if state then
       TweenPosition = UDim2.new(0,0,0,0)
    else
       TweenPosition = UDim2.new(1,0,0,0)
    end

    local Tween = TweenService:Create(RebirthUI.Main, TweenInfo.new(1), {Position = TweenPosition})
    Tween:Play()

    if waitUntilFinished then
        Tween.Completed:Wait()
    end
  
    return true
end

function Rebirth:UpdateRebirthUI(newRebirthLevel)
    local RebirthTable = Functions.GetRebirthTable:InvokeServer()
    print(RebirthTable[1])
    print(RebirthTable[2])
    print(newRebirthLevel)
    local currentMuliplier = RebirthTable[newRebirthLevel].Multiplier
    local nextMultiplier = RebirthTable[newRebirthLevel + 1].Multiplier

    local Cost = RebirthTable[newRebirthLevel + 1].Cost

    RebirthUI.Main.CurrentStats.EggMultiplier.Text = "x"..currentMuliplier
    RebirthUI.Main.CurrentStats.CoinMultiplier.Text = "x"..currentMuliplier
    RebirthUI.Main.NextStats.EggMultiplier.Text = "x"..nextMultiplier
    RebirthUI.Main.NextStats.CoinMultiplier.Text = "x"..nextMultiplier
end

Rebirth:UpdateRebirthUI(Player:WaitForChild("leaderstats").PlayerStats.Rebirths.Value)
Player:WaitForChild("leaderstats").PlayerStats.Rebirths.Changed:Connect(function(newValue)
    Rebirth:UpdateRebirthUI(newValue)
end)


return Rebirth

Based on that, I assume that newRebirthLevel is possibly being sent as a string? Also, just for clarification, are both multipliers nil or is it just the current multiplier? If your argument is passed as a string, it wouldn’t be able to find that value in the dictionary unless it’s a string.

Thanks, I cant believe i missed that. I sent the whole day trying to fix this bug when a simple tonumber would have worked.

1 Like