I tried to make a rebirth system in my game everything like the multipliers and such work, except actually leveling up. I created a gui that if you click the "okay" button and you have enough coins it will level you up, but it just will not work. There's no errors, or anything. Can someone help?

Server Script:





local datastoreService = game:GetService("DataStoreService")
local CoinsDataStore = datastoreService:GetDataStore("CoinsDataStore")
local RebirthsDataStore = datastoreService:GetDataStore("RebithDataStore")
local Required
game.Players.PlayerAdded:Connect(function(player)
    local data = Instance.new("Folder",player)
    data.Name = "Data"

    local folder = Instance.new("Folder",player)
    folder.Name = "Values"

    local coins = Instance.new("IntValue",data)
    coins.Name = "Coins" --Name "Wins" to what ever you want.
    coins.Value = 0

    local fake1 = Instance.new("StringValue",folder)
    fake1.Value = tostring(coins.Value)
    fake1.Name = tostring(coins.Name)

    local rebirths = Instance.new("IntValue",data)
    rebirths.Name = "Rebirths"

    local things = Instance.new("Folder",player)
    things.Name = "Thingys"

    local required = Instance.new("IntValue",things)
    required.Name = "Required"
    required.Value = Required

    local data
    local data2

    local success, errormessage = pcall(function()
        data = CoinsDataStore:GetAsync(player.UserId.."-Coins")
        data2 = RebirthsDataStore:GetAsync(player.UserId.."-Rebirths")
    end)

    if success then
        coins.Value = data
        rebirths.Value = data2
    else
        print("THERE WAS AN ERROR GETTING YOUR DATA STORE.")
        warn(errormessage)
    end

    while wait() do

     local x = tostring(coins.Value)
    if #x >= 14 then -- Trillions
            fake1.Value = x:sub(0,(#x-13)).."."..(x:sub(#x-11,(#x-11))).."T+"
     elseif #x >= 10 then --Billions
            fake1.Value = x:sub(0,(#x-9)).."."..(x:sub(#x-7,(#x-7))).."B+"
        elseif #x >= 7 then --Millions
            fake1.Value = x:sub(0,(#x-6)).."."..(x:sub(#x-5,(#x-5))).."M+"
        elseif #x >= 4 then --Thousands
            fake1.Value = x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
        else -- If it's not high enough...
         fake1.Value = tostring(coins.Value)
end
    end
    while wait() do
        Required = 1000 + (1*rebirths.Value)
    end

    game.ReplicatedStorage.Rebirth.OnServerInvoke = function()
        if player.Coins.Value == Required then
            rebirths.Value = rebirths.Value + 1
            coins.Value = 0
        end
    end
end)
game.Players.PlayerRemoving:Connect(function(player)

    local success, errorMessage = pcall(function()

    CoinsDataStore:SetAsync(player.UserId.."-Coins",player.Data.Coins.Value)

    RebirthsDataStore:SetAsync(player.UserId.."-Rebirths",player.Data.Rebirths.Value)
    end)
    if success then

        print(player.Name.." data saved successfully.")

    else
        print("There was an error saving data.")

        warn(errorMessage)

    end
end)







Local Script:





local replicatedStorage = game:GetService("ReplicatedStorage")
local rebirth = replicatedStorage:WaitForChild("Rebirth")

script.Parent.MouseButton1Click:Connect(function()
    rebirth:InvokeServer()
end)