Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

No errors When Player Humanoid dead and respawns not working??

Asked by 2 years ago

When Player dies and respawns the gui is suppose to go visible

01local Players = game:GetService("Players")
02game.Players.PlayerAdded:Connect(function(Player)
03    Player.CharacterAdded:Connect(function(Char)
04        Char.Humanoid.Died:Connect(function()
05            if Char.Humanoid.Health == 100 then
06            Player.PlayerGui.MainUI.Enabled = true
07                Player.PlayerGui.MoneyGui.Enabled = true
08                end
09        end)
10    end)
11end)

1 answer

Log in to vote
1
Answered by 2 years ago

I found a few errors on the script also you need to put a wait in there when the humanoid has 100 health because when the humanoid is still respawning the Gui goes visible. Here is the fixed script put it in serverscriptservice.

01local Players = game:GetService("Players")
02 
03game.Players.PlayerAdded:Connect(function(Player)
04 
05    Player.CharacterAdded:Connect(function(Char)
06 
07        Char.Humanoid.Died:Connect(function()
08 
09            if Char.Humanoid.MaxHealth == 100 then-- majour error you forgot to do MaxHealth
10 
11                wait(4)-- if you want to change this make the number greater than 4 because it takes about 3. something seconds to fully respawn
12 
13                Player.PlayerGui.MainUI.Enabled = true
14 
15                Player.PlayerGui.MoneyGui.Enabled = true
View all 23 lines...

Hope this helps!!

0
Thx it worked 666_brithday 103 — 2y
Ad

Answer this question