Ad
Log in to vote
0

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

Asked by 19 days ago

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

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

end)

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

2 answers

Log in to vote
0
Answered by 19 days ago
Edited 19 days ago

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)
0
Thank you aged_force9yt 0 — 19d
0
^Can you mark my answer as accepted if it helped? SuperLittleAdmin 177 — 19d
Ad
Log in to vote
0
Answered by 18 days ago

Maybe, it should be an event, like this

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

Answer this question