Basically, I have a GUI with a textbox, and in the textbox, you write the player’s name and then all the functions work on that specified player.
Currently I have:
for i,player in pairs(Players:GetChildren()) do
...
end
But it’s of course wrong, and I don’t know how to make it detect the player that was written in the TextBox
for some reason, after a specified amount of time, it stops working
code:
TextButton.MouseButton1Click:Connect(function()
print("click")
for _,player in pairs(Players:GetPlayers()) do
if player.Name == TextBox.Text then
print(player)
WantedModule.Wanted(player)
end
end
end)
TextButton.MouseButton1Click:Connect(function()
print("click") -- it prints this
for _,player in pairs(Players:GetPlayers()) do
print(player) -- it also prints this
if player.Name == TextBox.Text then
print(player) -- but it doesnt print this
WantedModule.Wanted(player, 150)
end
end
end)
local players = game:GetService('Players')
local textbox = script.Parent
textbox.FocusLost:Connect(function()
if textbox.Text ~= '' then
local chosenPlayer = players:FindFirstChild(textbox.Text)
if chosenPlayer then
--Handler
end
else
return
end
end)
local Textbox = where the textbox is
local Button = add a button as a Search thing
Button.MouseButton1Press:Connect(function()
for _, Player in pairs(game.Players:GetPlayers()) do
if Player.Name = Textbox.Text then – because its not string, u have to be correct with capitalization
end
end
end)