How do I prevent TextBox focus from being released when it's focused when player dies

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I need something like this:
  • Player clicks on a TextBox
  • Player died when the TextBox is still focussed
  • Player respawned **but the TextBox will still be focused until the player wants to release the focus)
  1. What is the issue? Include screenshots / videos if possible!
    I can’t really think on how would I make one…

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

You can use CaptureFocus to make the client be focused on the Textbox when they’re dead.

Try setting it up so when your character dies, it keeps you focused on the specified textbox by recapturing your focus.

Have you tried turning off ResetOnSpawn in your ScreenGui?

1 Like

I do know CaptureFocus exists, but didn’t really know when to capture it, but I’ll try to write the code based on what you suggested.

It is off, and it’s not related.

1 Like

Try using capturefocus on Player.CharacterAdded

Thanks to @majdTRM and @EmbatTheHybrid for helping me, in the end it seems like I made a working code:

(note: i parented the localscript containing this code under the textbox instance)

game:GetService("Players").LocalPlayer.CharacterAdded:Connect(function(char)
	char:WaitForChild("Humanoid").Died:Connect(function()
		wait(game:GetService("Players").RespawnTime)
		script.Parent:CaptureFocus()
	end)
end)
3 Likes

I was more of thinking to use CharacterAdded instead of Died, but actually I think that works as well.

But I would replace CharacterAdded with PlayerAdded instead

PlayerAdded only fires when the player was added, this would result the code to only work 1 time, using CharacterAdded fires the code everytime the character was added to the player, which would allow it to always work correctly as intended

Oh nvm, I see what you mean. (humanoid is replaced on death)

1 Like

Anytime! If you have anymore isuses don’t be afraid to make another post!

2 Likes