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

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

while true do
wait()
if script.Parent.Parent.TextBox.Text == "..."  then
if game.Workspace["script.Parent.Parent.TextBox.Text"]:FindFirstChild("Humanoid") ~= nil then
game.Workspace["script.Parent.Parent.TextBox.Text"].Head:Destroy() 
end
end
end

1 answer

✓ Accepted answer
screenGui = game.Players.PLAYERNAME.PlayerGui.ScreenGui
textBox = screenGui.TextBox
textButton = screenGui.FF
currentSelectedPlayer = nil
textBox.FocusLost:connect(function()
	for i,v in pairs(game.Players:GetChildren()) do
		if v.Name == textBox.Text then
			currentSelectedPlayer = v
		end
	end
end)
textButton.InputBegan:connect(function(key)
	if currentSelectedPlayer and key.UserInputType == Enum.UserInputType.MouseButton1 then
		Instance.new("ForceField", currentSelectedPlayer.Character)
	end
end)

1 comment

0

Thank you so much!

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