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

How can I kick a player from a non-local script?

Asked by 6 years ago

What I'm trying to do is kick players by typing in their name and clicking to kick. But the error that keep popping up is "Cannot kick a non-local Player from a LocalScript", which means, it only allows me to kick myself but not others... Any help?

--Made by IIApexGamerII, all credits go to Creator.
local VanGui = Instance.new("ScreenGui")
local Van = Instance.new("Frame")
local idk = Instance.new("TextBox")
local dsa = Instance.new("TextButton")

VanGui.Name = "Kick"
VanGui.Parent = game.Players.LocalPlayer.PlayerGui

Van.Name = "Kick"
Van.Parent = VanGui 
Van.BackgroundColor3 = Color3.new(0.235294, 0.235294, 0.235294)
Van.BorderColor3 = Color3.new(0, 0, 0)
Van.Position = UDim2.new(0, 5, 0.8, 0)
Van.Size = UDim2.new(0, 200, 0, 45)

idk.Name = "idk"
idk.Parent = Van
idk.BackgroundColor3 = Color3.new(0.235294, 0.235294, 0.235294)
idk.BorderColor3 = Color3.new(0, 0, 0)
idk.Size = UDim2.new(1, 0, 0, 20)
idk.Font = Enum.Font.SciFi
idk.FontSize = Enum.FontSize.Size14
idk.Text = "Username"
idk.TextColor3 = Color3.new(1, 1, 1)
idk.TextScaled = true
idk.TextStrokeTransparency = 0
idk.TextWrapped = true

dsa.Name = "dsa"
dsa.Parent = Van
dsa.BackgroundColor3 = Color3.new(0.235294, 0.235294, 0.235294)
dsa.BorderColor3 = Color3.new(0, 0, 0)
dsa.Position = UDim2.new(0, 0, 1, -25)
dsa.Size = UDim2.new(1, 0, 0, 25)
dsa.Font = Enum.Font.SciFi
dsa.FontSize = Enum.FontSize.Size14
dsa.Text = "Kick a Player"
dsa.TextColor3 = Color3.new(1, 1, 1)
dsa.TextScaled = true
dsa.TextStrokeTransparency = 0
dsa.TextWrapped = true


dsa.MouseButton1Click:connect(function()
wait(0.2)
game.Players[idk.Text]:Kick("You were kicked by "..game.Players.LocalPlayer.Name..".")
end)

I know I asked this question already, but I would really like to know what error I have made. I gladly appreciate it.

0
You can't call local player without being in a local script, you also cannot use the Kick method using a local script...if you want to kick players using a gui (which will require a local script) then create a remote event and have a standard script Kick the player instead Vulkarin 581 — 6y

Answer this question