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

How can i create kick system by clicking on a player?

Asked by 5 years ago
Edited 5 years ago
--This is a local script inside starter Gui and i am trying to make it so when i "target"player it will kick him but i am the one getting kicked + i cannot use click detector inside the player
wait(3)

local tool = Instance.new("Tool")

local players = game:GetService("Players")

tool.Parent = game.Players.LocalPlayer.Backpack

local mouse = game.Players.LocalPlayer:GetMouse()

tool.RequiresHandle = false



tool.Activated:Connect(function()

local hit = mouse.Target

local character = hit.Parent

if mouse.Target and mouse.Target.Parent then

local player = players:FindFirstChildOfClass("Player",character)

player:Kick("You've been kicked")

end

end)

1 answer

Log in to vote
0
Answered by 5 years ago

[https://developer.roblox.com/api-reference/function/Players/GetPlayerFromCharacter] use this function to find the player and then kick him

Ad

Answer this question