So, I have a textbox, and a textbutton. I want it so that when you type in the name of a player in the textbox, then click the textbutton, it kicks the player you typed in.. but I'm quite stumped. Any help? I'm not sure how to return what's typed in, to kick that player from game.Players.
I suppose you could consider this asking for help without having code.. but there's not much code for me to include other than defining variables:
local playerwk = game.Players.LocalPlayer -- player who kicked (to log that they kicked someone in a hint) local offender = script.Parent.Parent.Offender -- textbox, the offender that you're trying to kick function kickplr() end
Text
propertyOffender = textboxyouwanttocheck isPlayer= function(text) --checks if player is in players service return game.Players:FindFirstChild(tostring(text)) or nil end TextButton.MouseButton1Down:connect(function() local playerFromTextBox = isPlayer(Offender.Text) -- store returned value from function call in variable if playerFromTextBox then --if player is not nil --kick end end)
To get what the player typed into the text box, you need to see the text box's text property.
local textbox = script.Parent print(textbox.Text)
There is a Kick method so you could kick people...
game:GetService("Players").player:Kick()
You could also put a string inside the "()" so you could add a custom message.
local playerwk = game.Players.LocalPlayer -- player who kicked (to log that they kicked someone in a hint) local offender = script.Parent.Parent.Offender -- textbox, the offender that you're trying to kick function kickplr() local kick = game:GetService("Players"):FindFirstChild(offender.Text) if kick then kick:Kick(playerwk.Name.." has kicked you.") end end
Hope it helps!(My answer is better lolololol. maybe.)
I know that this has already been answered, but it can be re-answered, this is a lot easier than the other answers. Put this LocalScript inside the kick button.
local PlayerTK = game.StarterGui.ScreenGui.KickUI.textbox local PlayerWK = game.Players.LocalPlayer.Name script.Parent.MouseButton1Down:Connect(function(Kick) game.Players[PlayerTK]:Kick(¨You were kicked by ¨..PlayerWK) end)
If it doesn´t work, be aware that I haven´t scripted for a LONG time.