So when I have enough strength to rebirth, it doesn't let me rebirth.

I have 2 scripts. I don't get an error, but it doesn't work.

The first script is my remotes script, and the second script is a script in a ScreenGui located in StarterGui.

local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData")
local starterRebirthAmount = 5000
local cooldown = 0.3

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.Strength.Value = player.leaderstats.Strength.Value + 25 * (player.leaderstats.Rebirths.Value + 1)

		wait(cooldown)

		debounce.Value = false
	else
	end
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
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)

1 comment

0

Why tf would you say math.sqrt(1000000) when you could just say 1000????