yours didnt work so hopefully @Tornado_chaser04 's works
So adding on to what @Tornado_chaser04 said the code should look like this:
game.Players.PlayerAdded:Connect(function(player))
local char = player.Character
if char then
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
player.PlayerGui.GUI.Enabled = true
end)
end
end
end)
Note change “GUI” to the name of your GUI
Also what I previously posted wasn’t supposed to enable the ui but rather show you how to connect something to a players death
do you know where I should put the script?
ServerScriptService
30 CHAAARS
ok but why did u say 30 CHAAARS?
Yes and make sure the character actually exists though, since this is running when a player gets added and the character doesn’t exists when the game has been initialized then it will error
game.Players.PlayerAdded:Connect(function(player))
local success, errorMessage = pcall(function()
local char = player.Character
end)
if not success then
repeat
char = player.Character
wait()
until char
end
if char then
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
--Turn on the enabled property of the UI to make the UI visible again.
end)
end
end
end)
This would guarantee that the character is recognized by the server in case you are the first player in the server and the scripts run before your character even loads.
This script would be in ServerScriptService
I needed to get to the character minimum
So once again adding to @Tornado_chaser04 the final code for that script should be
game.Players.PlayerAdded:Connect(function(player))
local success, errorMessage = pcall(function()
local char = player.Character
end)
if not success then
repeat
char = player.Character
wait()
until char
end
if char then
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:Connect(function()
player.PlayerGui.GUI.Enabled = true
end)
end
end
end)
Once again change “GUI” to the name of your ScreenGui. Script Location: ServerScriptService
But its giving me errors on char
I think you should probably instance a value (eg. boolValue or stringValue) to the player when they load their chosen character and then in the humanoid.Died event, check if the value exists. If the value doesn’t exist, then set the Enabled property to true.
...
--Server Script
Player:LoadCharacterWithHumanoidDescription(humanoidDescription) -- I'm assuming this is how you load their humanoid description
local Loaded = Instance.new("boolValue",Player.Character)
Loaded.Name = "Loaded"
--Local Script
humanoid.Died:Connect(function()
if not character:FindFirstChild("Loaded") then
player.PlayerGui.GUI.Enabled = true
end
end)
I’m not sure if this works or not because Roblox is down for me right now.