RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"can you make a script that will kick the player who types the "!kick" command in chat"
-- server script local RunService = game:GetService("RunService") local Players = game:GetService("Players") local npc = script.Parent local rootPart = npc.HumanoidRootPart local humanoid = npc.Humanoid rootPart.Touched:Connect(function(hit) local player = Players:GetPlayerFromCharacter(hit.Parent) -- find the player if player then -- check if the player was found player.Character.Humanoid.Health = 0 -- damage the player end end) while true do for _, player in pairs(Players:GetPlayers()) do -- loop through all the players local playerRoot = player.Character and player.Character:FindFirstChild("HumanoidRootPart") -- get the player's humanoidrootpart if playerRoot and (playerRoot.Position - rootPart.Position).Magnitude <= 25 then -- check if the player is near the npc humanoid:MoveTo(player.Character.HumanoidRootPart.Position) -- move the npc humanoid.MoveToFinished:Wait() -- wait until the npc has reached the player (not sure if i should use movetofinished) break -- break the loop so it doesn't follow a different player end end RunService.Heartbeat:Wait() -- in case no player is near the npc end