This script isn't allowing me to rebirth more than once. Can anyone help with how to let me rebirth multiple times?

I have a rebirth script in a ScreenGui in StarterGUI, and a ServerScriptService script for RemoteFunctions and RemoteEvents.

The first code block is the GUI script, and the second being for RemoteFunctions and RemoteEvents.

local replicatedStorage = game:GetService("ReplicatedStorage")
local starterRebirthAmount = 5000

local player = game.Players.LocalPlayer
local mainFrame = script.Parent:WaitForChild("MainFrame")
local rebirthMenu = mainFrame:WaitForChild("RebirthMenu")
local mainButton = script.Parent:WaitForChild("MainButton")
local rebirthButton = rebirthMenu:WaitForChild("RebirthButton")
local strengthToRebirth = rebirthMenu:WaitForChild("StrengthToRebirth")
local rebirths = player:WaitForChild("leaderstats").Rebirths


strengthToRebirth.Text = "To rebirth, you will need "..math.floor((starterRebirthAmount + (rebirths.Value) * math.sqrt(1000000))).." strength to rebirth"

mainButton.MouseButton1Click:Connect(function()
	mainFrame.Visible = not mainFrame.Visible
end)

rebirthButton.MouseButton1Click:Connect(function()
	local result = replicatedStorage.Remotes.Rebirth:InvokeServer()
	
	if result == true then
		rebirthButton.Text = "Successfully Rebirthed!"
		wait(1)
		rebirthButton.Text = "CLICK HERE TO REBIRTH"
		
	elseif result == "NotEnoughStrength" then
		rebirthButton.Text = "Oh no! You don't have enough strength to rebirth. Keep Lifting!"
		wait(1)
		rebirthButton.Text = "CLICK HERE TO REBIRTH"
	end
end)

rebirths:GetPropertyChangedSignal("Value"):Connect(function()
	math.floor((starterRebirthAmount * (rebirths.Value) * math.sqrt(1000000)))
end)
replicatedStorage.Remotes.Rebirth.OnServerInvoke = function(player)
	
	if not remoteData:FindFirstChild(player.name) then return "NoFolder" end
	
	local rebirths = player.leaderstats.Rebirths
	
	if player.leaderstats.Strength.Value >= (math.floor((starterRebirthAmount * (rebirths.Value) * math.sqrt(1000000)))) then
		
		rebirths.Value = rebirths.Value + 1
		
		player.leaderstats.Strength.Value = 0
		
		player:LoadCharacter()
		
		return true
	else return "NotEnoughRebirth"
		
	end
end


1 comment

0

Where is the local script located?