local textbox = game.StarterGui.ScreenGui.TextBox local changed = textbox.Changed
changed:Connect(function() textbox.Text = ("die") if then script.Parent:Destroy() end
end)
local textbox = game.StarterGui.ScreenGui.TextBox local changed = textbox.Changed
changed:Connect(function() textbox.Text = ("die") if then script.Parent:Destroy() end
end)
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)
Thank you
^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.
1 comment
game.startergui contains the instance(s) that gets copy-pasted to the playergui, it is not the same as game.players.player.playergui