____ is not a valid member of workspace?

Hi! I need help with my Admin GUI.

  1. What do you want to achieve? I would like to make an Admin GUI which lets an admin kick, and basically do admin things.

  2. What is the issue? My kick button, when I type in a username comes up with an error, I’ll show it below.

  3. What solutions have you tried so far? I have not looked for solutions but I have tried multiple things in the code.

My code:

local textbox = script.Parent.Parent.Player

script.Parent.MouseButton1Click:Connect(function()
	local playerchar = workspace[textbox.Text]
	if playerchar then
		local player = game.Players:GetPlayerFromCharacter(playerchar)
		if player then
			if game:GetService("Players"):GetPlayerFromCharacter(player) then
				game.Players:GetPlayerFromCharacter(playerchar):Kick("Oh no! You've been kicked from the server by an admin. Maybe you did the wrong thing! If you believe you did nothing, then tell jahoobas.")
			end
		end
	end
end)

These are some screenshots:


two

Help will be appreciated!

local player = game.Players:GetPlayerFromCharacter(playerchar)
		if player then
			if game:GetService("Players"):GetPlayerFromCharacter(player) then

You’re fetching the player instance from its character and then attempting to fetch a player instance from that fetched player instance.

1 Like

That means the text was just “”. Try using :FindFirstChild() rather than using brackets.

Also, I would recommend using game:GetService("Players"):FindFirstChild(textbox.Text) rather than workspace:FindFirstChild(textbox.Text), since it skips the GetPlayerFromCharacter call.

For example, using your code:

local textbox = script.Parent.Parent.Player
local Players = game:GetService("Players")

script.Parent.MouseButton1Click:Connect(function()
	local player = Players:FindFirstChild(textbox.Text)
		if player and player:IsA("Player") then
			player:Kick("Oh no! You've been kicked from the server by an admin. Maybe you did the wrong thing! If you believe you did nothing, then tell jahoobas.")
		end
	end
end)

Using player:IsA(“Player”) isn’t terribly necessary, but since it’s possible for non-player objects to be in the Players service, it’s just in case.

I tried this, and it did not work
only got rid of the error

:Kick() when called from a local script can only be used to kick the local player.

You’ll need to use a RemoteEvent instance.

Sorry, this is a server script. :smiley:

Can you share a screenshot of the script’s location?

1 Like

Sure! I sure can. Here it is:
image

Okay, so changes to a TextBox’s text property (as a result of the player typing in text) does not replicate to the server, as such from the server’s perspective the Text property of the TextBox is unchanged.

Thank you, you made me realize my issue!