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

Where is this Error rebirths is not a valid member of Folder?

Asked by 5 years ago

i don't know where the error is in my script

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local staterRebirthAmount = 5000

local cooldown = 1

replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local debounce = remoteData[player.Name].Debounce

    if not debounce.Value then
        debounce.Value = true

        player.leaderstats.Shrinkage.Value = player.leaderstats.Shrinkage.Value + 10 * (player.leaderstats.rebirths.Value + 1)

        wait (cooldown)

        debounce.Value = false
    else

    end
end)

replicatedStorage.Remotes.Rebirths.OnServerInvoke = function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local rebirths = player.leaderstats.Rebirths

    if player.leaderstats.Shrinkage.Value >=(math.floor((starterRebirthAmount + (rebirths.value) + math.sqrt(50000000)))) then

        rebirths.Value = rebirths.Value + 1

        player.leaderstats.Shrinkage.Value = 0

        player:LoadCharacter()

        return true
    else return "Not enough shrinkage"
    end
end

1 answer

Log in to vote
0
Answered by
OnaKat 444 Moderation Voter
5 years ago

Try add this

repeat wait() until player.leaderstats:FindFirstChild("Rebirths")
local rebirths = player.leaderstats.Rebirths

if this not work, that mean there is no Rebirths in the leaderstats folder.

Ad

Answer this question