Hello Forum Members,
I believe in the forum since you’ve all helped e lightning fast. Generally, the answer is very obvious, such as a misspelling etc, but I never catch them. Right now, I have no idea what I did wrong but it’s very confusing. I’m making an AdminGUI for my developers to use in public servers/just have fun, and I made a ‘kill’ power. You enter the name of the person you want to kill in the text box, and it kills them. The problem is not what I thought it would be. When ever I try to get what the player put in the textbox, (TextBox.Text) its blank, even though theres something there. The script then identifies the blank as an invalid target and sends out a warning. If I set TextBox.Text to rnaximos(in the script, not the textbox), it kills me no matter what I put in there. I’ve already checked and the script is in fact linked to the right textbox. I ran a test but it didnt detect a text input. Also, when I set TextBox.Text to rnaximos in the script, it said TextBox in the text field and no matter what I put in there I died.
local button = script.Parent --this is the button confirming the user's input
local getUsername = script.Parent.Parent.UsernameBox --this is the textbox
--Services
local Players = game:GetService("Players")
--Functions
local function CheckForTarget(Target)
if not Target then
warn('Target is not valid.')
else
print('Target is valid.')
return true
end
end
button.MouseButton1Click:Connect(function()
print(getUsername.Text)
local Target = Players:FindFirstChild(getUsername.Text)
local Valid = CheckForTarget(Target)
if Valid then
Target.Character.Head:Destroy()
end
if not Valid then
warn("Invalid target.")
end
end)