Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to input player's username on TextBox to run certain commands on them?

Asked by
Jxdenx 45
7 years ago
1while true do
2wait()
3if script.Parent.Parent.TextBox.Text == "..."  then
4if game.Workspace["script.Parent.Parent.TextBox.Text"]:FindFirstChild("Humanoid") ~= nil then
5game.Workspace["script.Parent.Parent.TextBox.Text"].Head:Destroy()
6end
7end
8end

1 answer

Log in to vote
0
Answered by
blowup999 659 Moderation Voter
7 years ago
01screenGui = game.Players.PLAYERNAME.PlayerGui.ScreenGui
02textBox = screenGui.TextBox
03textButton = screenGui.FF
04currentSelectedPlayer = nil
05textBox.FocusLost:connect(function()
06    for i,v in pairs(game.Players:GetChildren()) do
07        if v.Name == textBox.Text then
08            currentSelectedPlayer = v
09        end
10    end
11end)
12textButton.InputBegan:connect(function(key)
13    if currentSelectedPlayer and key.UserInputType == Enum.UserInputType.MouseButton1 then
14        Instance.new("ForceField", currentSelectedPlayer.Character)
15    end
16end)
0
Thank you so much! Jxdenx 45 — 7y
Ad

Answer this question