How would I make something like this?

Hello everyone!

So I want to make something where you click on a player in-game, and it does something to them (for example, killing/freezing them, etc) but I’m not quite sure how to go about making it.

Any help will be appreciated. Thanks!


try using a use click detector object

Inside of StarterCharacterScripts, insert a script:

Now write this:

local char = script.Parent

local torso = char:WaitForChild("UpperTorso")

local cd ="ClickDetector")

cd.Parent = torso

cd.MaxActivationDistance = 10




you could use a tool with, this could check send a remote event to the targeted player and choose a random fate

1 Like

Place it inside a players torso or head.(or wherever you want the clicking to take place)

Yes, this is the basic structure of a click detector script…Use this…

1 Like

Use mouse.Target, and hook up a function to a InputBegan event, check if the the parent of mouse.Target has a humanoid in it and if the name of it matches a player in the game, and if it does then do the stuff you wanna do with the player.

Or if you prefer an approach with Mouse.Target, use this:

Insert a Local Script inside of StarterPlayerScripts, and write:

local plr = game.Players.LocalPlayer -- Finding the player
local mouse = plr:GetMouse() -- Getting the mouse

 if mouse.Target.Name == "HumanoidRootPart" then -- Checking to see if it is part of a character
    if mouse.Target.Parent.Name ~= plr.Name then -- Making sure they can't damage themselves
	    	mouse.Target.Parent.Humanoid:TakeDamage(10) -- Taking damage

that wont work since it won’t affect the entire character and also the humanoid root part is like inside of the torso so it wouldn’t detect

Tried it out and it detected it :wink:

Although, using UpperTorso would be more efficient in a way…

it won’t detect the head arms etc though

Have a look at this:

try detecting the actual players group, it will pick up the whole player then