Can't Get a script to take info from a Text Box

My Issue:

I’m making a spawner and Im also having an admin tab where admin’s can use it if needed for things such as checking model info of spawnable items and kicking a player. My issue is that when I type in a Text Box a player name or anything, it gives me this error:
image
Anyone got any ideas? It looks like it gets a blank value.

Heres my code:

local Player = script.Parent.Parent.PlayerName.Text

script.Parent.MouseButton1Click:Connect(function()
	game.Players[Player]:Kick('An Admin has kicked you from this route session.')
end)
1 Like

It’s because the “Player” variable refers to the actual text of the textbox at the moment the game stats, not the PROPERTY of “text.” (so even if you change the text, it’ll still be referring to the text that was at the start of the game). Instead, do this:

script.Parent.FocusLost:Connect(function()
 game.Players[script.Parent.Text]:Kick('An Admin has kicked you from this route session.')
end)
1 Like

I will see if that works! Thanks for the heads up!

1 Like

@roblox_user_54556995 Hmmm, that stil gave me the same error…

1 Like

Make sure it’s a local script. It’s also case sensitive btw

2 Likes

I know its case sensitive, It’s not a local script though…

1 Like

The make sure to change that and make it local.

1 Like

Ahh it works! Thanks! I appreciate it!

1 Like

Wait is the TextBox located because if it’s in STarterGUI you will need to fire a Remote event or function