What do you want to achieve? I would like to make an Admin GUI which lets an admin kick, and basically do admin things.
What is the issue? My kick button, when I type in a username comes up with an error, I’ll show it below.
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)
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.
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.