Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

Does anyone know how to make the code and where to add it?

0

use touched function and player:Kick()

2 answers

✓ Accepted answer

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.

1 comment

0

thanks dude

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.