Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I cant find a fix im trying to make a a textbox and when you put die you die?

local textbox = game.StarterGui.ScreenGui.TextBox local changed = textbox.Changed

changed:Connect(function() textbox.Text = ("die") if then script.Parent:Destroy() end

end)

1 comment

0

game.startergui contains the instance(s) that gets copy-pasted to the playergui, it is not the same as game.players.player.playergui

2 answers

GetPropertyChangedSignal fires if the property inside it changes

string.lower makes sure if player inputs ‘Die’, ‘diE’, or ‘die’, it all works.

Set local player’s hp to 0 if text passed the condition

local textbox = game.Players.LocalPlayer.PlayerGui:WaitForChild('ScreenGui').TextBox

textbox:GetPropertyChangedSignal('Text'):Connect(function()
	if string.lower(textbox.Text) == 'die' then
		game.Players.LocalPlayer.Character.Humanoid.Health = 0
	end
end)

2 comments

0

Thank you

0

^Can you mark my answer as accepted if it helped?

Maybe, it should be an event, like this

if textbox.Text == "Die" then
local plr = game.Players.LocalPlayer.Character
plr.Humanoid.Health = 0

This discussion is preserved as it was. New answers, comments, and votes are closed.