Problems with this LocalScript

I am trying to make a GUI that appears and says random text when you die, that all works, but the problem is, when it disables, it never enables again (unless I do it manually), how can I solve this?

Here’s the code:

local player = game:GetService("Players").LocalPlayer
local playerGui = player.PlayerGui
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

humanoid.Died:Connect(function()
	playerGui.LolGui.Enabled = true
	wait(3)
	playerGui.LolGui.Enabled = false
end)

All kinds of help will be appreciated,
Thanks.

1 Like

Could you elaborate? The script you provided works perfectly as expected to me.

When I reset, the text appears,
but if I reset once again, it just doesn’t work.

I used TextLabel, by the way.
The Console doesn’t show a thing or doesn’t yell out anything.

Quite confusing as that should work.

Perhaps try turning off resetOnSpawn? Not sure if that would do anything though

I tried with a ScreenGui that has ResetOnSpawn true, that worked. Can’t figure out what could happen, it works perfectly for me.

Tried that, still no luck.
I am starting to think that Roblox just hates me.
And ResetOnSpawn completely messed up the Sentence table.

That has absolutely nothing to do with the issue we’re talking about. Also, your reply seems to be generated by a certain service offered by OpenAI, so please consider what you’re replying.

1 Like

I don’t think using wait() is the issue

I think the problem is when the code runs, it sets an enable for the LolGui to 3 seconds.

After the 3 seconds, I believe the code is making the GUI disable for 4 seconds, but it’s hard to tell, because there is no line to end the disable part.

Yeah dude, here:

	playerGui.LolGui.Enabled = true
	wait(3)
	playerGui.LolGui.Enabled = false -- <-

This script is perfectly fine. It works as intended for me, so it must be some property configuration.

Try the same experiment again, but wait 4 seconds before resetting the second time.

1 Like

We’ve already said that it does absolutely nothing. Let me attach a video real quick.

Exactly tried to do that
but still nothing

Same here,

I just tried it in Roblox studio and it worked for me

@TevziFish is there anything (scripts etc) interacting with your gui?

When the player dies, the character is removed, meaning the connection to the humanoid is destroyed.

Try putting the humanoid.died event connection inside another connection to detect whenever the character loads

-- Don't wait for the character beforehand.

player.CharacterAdded:Connect(function(character)
    local humanoid = character:WaitForChild("Humanoid")
    humanoid.Died:Connect(...)
end)

@TevziFish

1 Like

Try this it does the exact same thing but its less cluttered

local player = game:GetService("Players").LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid") 
Humanoid.Died:Connect(function() 
    playerGui.LolGui.Enabled = true
    wait (5)
    playerGui.LolGui.Enabled = false
end)

nope
I dont think anything is
just the sentence localscript and the textlabel

it it just me or is his humanoid and character not capitals

boom 1 line of code

playerGui.LolGui.Enabled = Humanoid.Died:GetFirst()

O: