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 1 year ago

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

local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Char)
        Char.Humanoid.Died:Connect(function()
            if Char.Humanoid.Health == 100 then
            Player.PlayerGui.MainUI.Enabled = true
                Player.PlayerGui.MoneyGui.Enabled = true
                end
        end)
    end)
end)

1 answer

Log in to vote
1
Answered by 1 year 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.

local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(Player)

    Player.CharacterAdded:Connect(function(Char)

        Char.Humanoid.Died:Connect(function()

            if Char.Humanoid.MaxHealth == 100 then-- majour error you forgot to do MaxHealth

                wait(4)-- if you want to change this make the number greater than 4 because it takes about 3. something seconds to fully respawn 

                Player.PlayerGui.MainUI.Enabled = true

                Player.PlayerGui.MoneyGui.Enabled = true

                end

        end)

    end)

end)

Hope this helps!!

0
Thx it worked 666_brithday 103 — 1y
Ad

Answer this question