print("username located") print(username) local players = game.Players function kick() print("Running function") local username = script.Parent.Parent.Userkicker.Text print("username located") print(username) print("kicking") players.username:kick() print("player kicked") end script.Parent.MouseButton1Click:connect(kick)
players.username:kick()
gives an error stating: 14:18:43.100 - username is not a valid member of Players
I dont know how to make the variable work in a middle of a path.
players[username]:Kick()
instead of
players.username:Kick()
Im retarded...
Your problem is probably you spelled username incorrectly, do "Username".
Your script should look more like this with a few fixes;
print("Username located") print(Username) local players = game.Players function kick() print("Running function") local Username = script.Parent.Parent.Userkicker.Text print("Username located") print(Username) print("kicking") players.Username:kick() print("player kicked") end script.Parent.MouseButton1Down:connect(kick)
If the script on top doesn't work then try this;
print("UserName located") print(UserName) local players = game.Players function kick() print("Running function") local UserName = script.Parent.Parent.Userkicker.Text print("UserName located") print(UserName) print("kicking") players.UserName:kick() print("player kicked") end script.Parent.MouseButton1Down:connect(kick)
If worked make sure to accept answer :D