I'm trying to make an on death GUI and when I die it works fine, It says how much time you wait to spawn (5 seconds) but when it gets to 1 it waits a couple seconds more and then it disappears. I tried so many ways to change it and it doesn't work. Please help me, I would really appreciate it if you do.
Script 1:
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:connect(function() script.Parent.Visible = true end)
Script 2:
while true do wait(0.1) if script.Parent.Parent.Visible == true then script.Parent.Text = "Spawning you in: 5 Seconds." wait(1) script.Parent.Text = "Spawning you in: 4 Seconds." wait(1) script.Parent.Text = "Spawning you in: 3 Seconds." wait(1) script.Parent.Text = "Spawning you in: 2 Seconds." wait(1) script.Parent.Text = "Spawning you in: 1 Seconds." while true do wait(0.1) if game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Health ~= 0 then script.Parent.Parent.Visible = false end end end end
(The if part is kinda glitched)
Thanks, MajinBluee
A devforum post was made about customizable reset logic. https://devforum.roblox.com/t/customizable-reset-button-logic/30463
It involves making a custom callback for the reset. You then could use that to maybe fire some remote event called RespawnClient()
since :LoadCharacter()
(http://wiki.roblox.com/index.php?title=API:Class/Player/LoadCharacter) can only be used on the server
The code for such logic would work something like this.
Client Side:
local respawnPlayer = game:GetService("ReplicatedStorage"):WaitForChild("RespawnPlayer") local resetCallBackEvent = Instance.new("BindableEvent") local untilRespawn = 10 local function resetCallback() wait(untilRespawn) respawnPlayer:FireServer() end resetCallBackEvent.Event:Connect(resetCallback) game:GetService("StarterGui"):SetCore("ResetButtonCallback", resetCallBackEvent)
Server Side:
local respawnPlayer = game:GetService("ReplicatedStorage"):WaitForChild("RespawnPlayer") local function respawn(player) player:LoadCharacter() end respawnPlayer.OnServerEvent:Connect(respawn)
This ofcourse only applies to resetting but you could probably find a hacky way to get past that.