Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my kick GUI not kicking players? (assigning variables to textbox.text)

Asked by
Jxyzxrr 13
5 years ago

local input = game.StarterGui.ScreenGui.Frame.TextBox.Text

game.Players.PlayerAdded:connect(function(plr)

if input == plr.Name then

input:Kick()

end

end)

This script does not work, why?

0
You're using Kick() on a property. Do plr:Kick(). DeceptiveCaster 3761 — 5y
0
exploitable EXpodo1234ALT 18 — 5y

2 answers

Log in to vote
0
Answered by
blockmask 374 Moderation Voter
5 years ago

Ok, so you are trying to kick a string or a text. That's like doing "roblox":Kick(), That won't work since Kick() requires a player instance to function. And what if the textboxe's text wasn't exactly the players name? We could lower case all all of the string's text and the player's name to see if it matches.

 local input = Textbox.Text

game:GetService("Players").PlayerAdded:Connect(function(player)
    if string.lower(input) == string.lower(player.Name) then
        player:Kick("You have been kicked by some random person lmao")
    end
end)
0
string.lower() allows you to do something like enter RoBloXFan, which turns it all into lowercase(robloxfan) blockmask 374 — 5y
Ad
Log in to vote
0
Answered by 3 years ago

You have to put the local script in a screenGui that has the Frame or TextBox. Then instead of game.StarterGui.ScreenGui.TextBox.Text, do

local input = script.Parent.TextBox.Text

-- Do the function Next --

Answer this question