I really need some help with a problem that I have been trying to troubleshoot for over a month now. Don’t laugh, I’m new. I have a rebirth button, with a LocalScript, that opens the rebirth menu, determines whether or not the player has enough cash to rebirth and displays the related text. That seems to be working fine.
There are other LocalScripts attached to specific rebirth selection buttons (Health in this example) that fires a ServerScript via RemoteEvent. The ServerScript verifies if the player has enough cash to rebirth, and then increases their rebirth count, increases their health and resets the TextLabel in the Rebirth GUI to show how much cash they need to rebirth again. This is where the problem occurs.
The ServerScript is rebirthing correctly, blanks out their cash, and even displays the correct TextLabel showing how much cash they need to rebirth again. However, it is not disabling the visibility on the “rebirthReady” TextLabel. It’s driving me crazy and again, I’ve tried been troubleshooting it for over a month now. All scripts are below and any help would be GREATLY appreciated.
Please be kind and remember, I’m very new to development. Also - I apologize for the length but wanted to make sure it was all there.
Rebirth Button LocalScript to open Menu (Working)
local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local leaderstats = player:WaitForChild("leaderstats")
local pCash = leaderstats:FindFirstChild("Cash")
local pRebirths = leaderstats:FindFirstChild("Rebirths")
local rebirthMenu = playerGui:WaitForChild("rebirthMenu")
local mainFrame = rebirthMenu:WaitForChild("mainFrame")
local cashLeftMsg = rebirthMenu.mainFrame:WaitForChild("rebirthCashLeft")
local notEnoughCashMsg = rebirthMenu.mainFrame:WaitForChild("notEnoughCash")
local rebirthReadyMsg = rebirthMenu.mainFrame:WaitForChild("rebirthReady")
local panelButton = script.Parent
local cashRebirthStartingValue = 10
local cashRebirthFactor1 = 150
local cashRebirthFactor2 = 0.4
local cashRebirthFactor3 = 15
function rebirthPanelButton()
if rebirthMenu.Enabled == false then
rebirthMenu.Enabled = true
if pRebirths.Value == 0 then
local cashRequired = cashRebirthStartingValue
if pCash.Value >= cashRequired then
cashLeftMsg.Visible = false
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = true
else
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = false
cashLeftMsg.Visible = true
cashLeftMsg.Text = tostring(cashRequired - pCash.Value).." More Cash to Rebirth!"
end
else
local cashRequired = (pRebirths.Value * cashRebirthFactor1) / cashRebirthFactor2 + (pRebirths.Value * cashRebirthFactor3)
if pCash.Value >= cashRequired then
cashLeftMsg.Visible = false
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = true
else
cashLeftMsg.Visible = true
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = false
cashLeftMsg.Text = tostring(cashRequired - pCash.Value).." More Cash to Rebirth!"
end
end
else
rebirthMenu.Enabled = false
end
end
panelButton.MouseButton1Click:Connect(rebirthPanelButton)
LocalScript to Fire Remote ServerScript (Working)
local repStore = game:GetService("ReplicatedStorage")
local healthEvent = repStore:WaitForChild("rebirthHealthEvent")
local healthButton = script.Parent
healthButton.MouseButton1Click:Connect(function()
healthEvent:FireServer()
end)
Rebirth ServerScript (Script makes all changes except disabling visibility on rebirthRdyMsg TextLabel)
local repStore = game:GetService("ReplicatedStorage")
local healthEvent = repStore:WaitForChild("rebirthHealthEvent")
local cashRebirthStartingValue = 10
local cashRebirthFactor1 = 150
local cashRebirthFactor2 = 0.4
local cashRebirthFactor3 = 15
local db = true
-- Function Fired when Player Clicks the Health Rebirth Button ------------------------------------------------------------------------------
local function healthButtonPressed(player)
local leaderstats = player:WaitForChild("leaderstats")
local pCash = leaderstats:FindFirstChild("Cash")
local pRebirths = leaderstats:FindFirstChild("Rebirths")
local playerStats = player:WaitForChild("PlayerStats")
local pHealth = playerStats:FindFirstChild("Health")
local pMaxHealth = playerStats:FindFirstChild("MaxHealth")
local playerGui = player:WaitForChild("PlayerGui")
local rebirthMenu = playerGui:WaitForChild("rebirthMenu")
local healthButton = rebirthMenu.mainFrame.buttonFrame:WaitForChild("rebirthHealthButton")
local cashLeftMsg = rebirthMenu.mainFrame:WaitForChild("rebirthCashLeft")
local notEnoughCashMsg = rebirthMenu.mainFrame:WaitForChild("notEnoughCash")
local rebirthReadyMsg = rebirthMenu.mainFrame:WaitForChild("rebirthReady")
local rebirthHeader = rebirthMenu.mainFrame:WaitForChild("Rebirths")
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local statsMenu = playerGui:WaitForChild("statsMenu")
local statPanel = statsMenu:WaitForChild("mainFrame"):WaitForChild("buttonFrame"):WaitForChild("statPanel")
local healthLabel = statPanel:WaitForChild("healthStat")
if db then
if pRebirths.Value == 0 then
local cashRequired = cashRebirthStartingValue
if pCash.Value >= cashRequired then
db = false
pRebirths.Value = pRebirths.Value + 1
pCash.Value = 0
pMaxHealth.Value = pMaxHealth.Value + 10
humanoid.MaxHealth = humanoid.MaxHealth + 10
pHealth.Value = pHealth.Value + 10
humanoid.Health = humanoid.Health + pHealth.Value
healthLabel.Text = humanoid.Health
rebirthHeader.Text = "Rebirths: "..tostring(pRebirths.Value)
local cashRequired = (pRebirths.Value * cashRebirthFactor1) / cashRebirthFactor2 + (pRebirths.Value * cashRebirthFactor3)
cashLeftMsg.Text = tostring(cashRequired - pCash.Value).." More Cash to Rebirth!"
cashLeftMsg.Visible = true
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = false
else
cashLeftMsg.Visible = false
rebirthReadyMsg.Visible = false
notEnoughCashMsg.Visible = true
wait(2)
notEnoughCashMsg.Visible = false
cashLeftMsg.Visible = true
end
else
local cashRequired = (pRebirths.Value * cashRebirthFactor1) / cashRebirthFactor2 + (pRebirths.Value * cashRebirthFactor3)
if pCash.Value >= cashRequired then
db = false
pRebirths.Value = pRebirths.Value + 1
pCash.Value = 0
pMaxHealth.Value = pMaxHealth.Value + 10
humanoid.MaxHealth = humanoid.MaxHealth + 10
pHealth.Value = pHealth.Value + 10
humanoid.Health = humanoid.Health + 10
healthLabel.Text = humanoid.Health
rebirthHeader.Text = "Rebirths: "..tostring(pRebirths.Value)
local cashRequired = (pRebirths.Value * cashRebirthFactor1) / cashRebirthFactor2 + (pRebirths.Value * cashRebirthFactor3)
cashLeftMsg.Text = tostring(cashRequired - pCash.Value).." More Cash to Rebirth!"
cashLeftMsg.Visible = true
notEnoughCashMsg.Visible = false
rebirthReadyMsg.Visible = false
else
rebirthReadyMsg.Visible = false
cashLeftMsg.Visible = false
notEnoughCashMsg.Visible = true
wait(2)
notEnoughCashMsg.Visible = false
cashLeftMsg.Visible = true
end
end
wait(0.5)
db = true
else
wait(0.5)
db = true
end
end
healthEvent.OnServerEvent:Connect(healthButtonPressed)