How do I make an Executeing system?

Hello people,

So in Rogue Lineage, There is this ‘gripping’ system, where you execute knocked out players, and I want to copy what rogue did.

I have already made a knocking system, and I would like to know how I can use the keyboard or Gui to kill a player

2 Likes

Take a look at this article: UserInputService | Documentation - Roblox Creator Hub

This is on the client side, so you’ll need to fire a remote event to the server.

1 Like

How would i know how far you are from a player?

Take a look at this: Player | Documentation - Roblox Creator Hub.

I’m not 100% familiar but a simple google search helped.

1 Like

I dont really understand, how would I know if a player’s distance is close enough to kill? would the script look like this?

Lets pretend the dummy is a ko’d player

local player = game.Players.LocalPlayer
local target = game.Dummy
local distance = player:DistanceFromCharacter(Target.HumanoidRootPart.CFrame.Position)
local player = game.Players.LocalPlayer
local target = workspace.Dummy
local distance = player:DistanceFromCharacter(target.HumanoidRootPart.Position)

if distance < 8 then
print'close enough to kill'
else
print("too far from target", distance)
end

how would i know where the nearest ko’d player is?

using a pairs loop to check all the positions compared to player

2 Likes

would this work? But how about monsters that you knock out (npcs)

local killables = {}

for i, v in pairs(game.Players:GetChildren()) do
local targetchar = v.Character
local distance = player:DistanceFromCharacter(targetchar.HumanoidRootPart.Position)
if distance < 8 then
table.Insert(killables, v.Name)
else
print("too far from target", distance)
end
end

Yes, that should work!
I mean from what I see here :smiley:

What can i do to detect knocked npcs?

Just do the same thing you did with the players, but with the NPCs’ characters instead

local Players = game:GetService'Players'
local LocalPlayer = Players.LocalPlayer

local KillableCharacters = {}

for i, Player in pairs(Players:GetPlayers()) do
	local TargetCharacter = Player.Character
	local Distance = LocalPlayer:DistanceFromCharacter(TargetCharacter.HumanoidRootPart.Position)
	if Distance < 8 then
		table.Insert(KillableCharacters, TargetCharacter)
	end
end

-- assuming you have a folder in workspace named "NPCs" that has all NPCs
for i, NPC in pairs(workspace.NPCs:GetChildren()) do
	local TargetCharacter = NPC
	local Distance = LocalPlayer:DistanceFromCharacter(TargetCharacter.HumanoidRootPart.Position)
	if Distance < 8 then
		table.Insert(KillableCharacters, TargetCharacter)
	end
end
local Players = game:GetService'Players'
local LocalPlayer = Players.LocalPlayer
local UserInput = game:GetService("UserInputService")
local db = true

local KillableCharacters = {}

UserInput.InputBegan:Connect(function(input,gameprocessed)
	if input.KeyCode == Enum.KeyCode.V then
		if db then
			db = false
				for i, Player in pairs(Players:GetPlayers()) do
				local TargetCharacter = Player.Character
				local Distance = LocalPlayer:DistanceFromCharacter(TargetCharacter.HumanoidRootPart.Position)
				if Distance < 8 then
					table.Insert(KillableCharacters, TargetCharacter)
				end
			end
			for i, NPC in pairs(workspace.NPCs:GetChildren()) do
				local TargetCharacter = NPC
				local Distance = LocalPlayer:DistanceFromCharacter(TargetCharacter.HumanoidRootPart.Position)
				if Distance < 8 then
					table.Insert(KillableCharacters, TargetCharacter)
				end
			end
			local randomkillable = KillableCharacters[math.random(1,#KillableCharacters)]
			--plays an animation
			local killablehum = randomkillable:FindFirstChidOfClass('Humanoid')
			killablehum.Health = 0
			wait(0.1)
			db = true
		end
	end
end)

this should work right?

Setting the humanoid’s health to 0 in a LocalScript won’t replicate to the server, you should fire a remote event instead and then set the health on the server

oh right… my bad, but is it possible to play an animation for another player with a local script? or no

I tweaked the script a little, and it works now. Thanks!

Yes, animations are not affected by the Filtering Enabled update