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

I want to know how to make a object and when it hits you it kicks you from the game?

Asked by
07jwv07 10
3 years ago

I am hopeless when it comes to complicated stuff like this so i would like some help.

I would like to make it so when i hit or tap someone with this object it kicks them from my game, i would like to know if anyone knows how to code any of this stuff so i can make it. I would also like to know if i need to make a code where will i put it? Into the object and make a script? Could someone please help?

0
Does anyone know how to make the code and where to add it? 07jwv07 10 — 3y
0
use touched function and player:Kick() Friskyman321 121 — 3y

2 answers

Log in to vote
0
Answered by
Auxigin 47
3 years ago

Here:

script.Parent.Touched:Connect(function(person)
    local hum = person.Parent:FindFirstChild("Humanoid")
    if hum then
        local plr = game.Players:GetPlayerFromCharacter(person.Parent)
        plr:Kick("Put the kicked message here")
    end
end)

Put this inside the part you want the player to touch that kicks them.

0
thanks dude 07jwv07 10 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

This might help:

local players = game:GetService("Players") --Gets the player service
local LocalPlayer = players.LocalPlayer -- Finds the player
local part = --Define where the part that needs to be touched is

repeat wait() until LocalPlayer.Character -- Waits until a player joins the game

local function kick() -- Defines what happens when the function is fired
    LocalPlayer:Kick("Exploiting") -- Kicks the player. You can write your own reason for kicking
end

part.Touched:Connect(kick) --Fires the function above when the part is touched.

Hopefully it helped!

Answer this question