Detecting playing knocking another player off the map

I’m making a game where I want a knockout system so when a player knocks someone off the map they get 1 “KO” added to the leaderboard so i’m guessing you would have a number value in a leaderstat and add 1 to it when the player knocks someone off the map but how would I go about detecting this.

any help is appreciated.

Weapon Script

local clientCast = require(game.ServerStorage.ClientCast)

local db = false
local debounce = false

local slash

for i = -0.9,2.9,.1 do
	local attachment = Instance.new("Attachment",script.Parent.Handle)
	attachment.Name = "DmgPoint"
	attachment.Position = Vector3.new(0,i,0)
end

local casterParams = RaycastParams.new()
casterParams.FilterDescendantsInstances = {script.Parent.Parent.Parent.Character or script.Parent.Parent.Parent.Parent.Character, script.Parent.Handle}
casterParams.FilterType = Enum.RaycastFilterType.Blacklist

local slashCaster = clientCast.new(script.Parent.Handle, casterParams)

slashCaster.HumanoidCollided:Connect(function(result, hithumanoid)
	local Tool = script.Parent
	local ToolP = Tool.Parent
	local sound = Tool.Handle.Hit
	local h = Tool.Parent:FindFirstChild("Humanoid")
	
	local bv = Instance.new("BodyVelocity")
	local offset = Vector3.new()
	bv.MaxForce = Vector3.new(10000000,10000000,10000000)
	bv.Velocity = h.Parent.Head.CFrame.LookVector * 55
	bv.Parent = (hithumanoid.Parent.HumanoidRootPart)
	wait(0.01)
	bv:Destroy()
	if hithumanoid.Parent:FindFirstChild("Effects") then
		if not hithumanoid.Parent.Effects:FindFirstChild("Ragdoll") then
			local z = Instance.new("BoolValue", hithumanoid.Parent.Effects)
			z.Name = "Ragdoll"
			local Debris = game:GetService("Debris")
			Debris:AddItem(z, 2.5) 
			task.wait(0.1)

		if not debounce then
			debounce = true
			sound:Play()
			local Effect = game.ReplicatedStorage.HitBlock:Clone()
			Effect.Parent = game.Workspace.HitEffects

			Effect.CFrame = ToolP:GetPrimaryPartCFrame() * CFrame.new(0, -1, -4)
			Effect.hitFx:Emit(5)
			local Debris = game:GetService("Debris")
			Debris:AddItem(Effect,0.5) 
			task.wait(0.2)
			debounce = false

			end
		end
	end
end)

script.Parent.Equipped:Connect(function()
	local humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
	if not slash then slash = humanoid:LoadAnimation(script.Animation); slash.Priority = Enum.AnimationPriority.Action2 end	
end)


script.Parent.Activated:Connect(function()
	local Cooldown = script.Parent.Configuration.Cooldown
	local ss = script.Parent.Handle.Swing
	if not db then
		db = true
		slash:Play()
		ss:Play()
		slashCaster:Start()
		wait(.5)
		slashCaster:Stop()
		wait(Cooldown.Value)
		db = false
	end
end)

script.Parent.Unequipped:Connect(function()
	if slash then slash:Stop() end
	slashCaster:Stop()
end)

Clip of how it would work

then player will get a 1 "KO"

When a player(1) hits another player(2), They would Change a Stringvalue in player2, to player1’s name. Then, If a player2 falls off the map, you could detect it by player2’s Y coordinates, or with an invisible part under the map using a touched event. Then the script would search in player2’s Stringvalue for the name or the last player who hit him, then player1 would get +1 KO’s. Got It?

1 Like

yeah just add a spatial query hitbox below the baseplate and see who died and what @PiercedMissile said, add a string value to remember the last person
.

1 Like

plr1 hits plr2 and adds value to plr2, waits till plr2 landed then waits an extra 2 seconds and checks if hes still on land then delete value, if hes in the air again wait till he lands then delete value.

When a hitbox detects hes in the void check if he has a value in him and give that person a point.

This is if you dont want it to give a person who hit him years ago a point if he jumps off the map or something.

1 Like

So you need to establish where the ring border is. You also need to fireserver a server script to change the leaderstats value

local Debris=game:GetService(“Debris”)

function TagHumanoid(Character,TargetHumanoid)
local KnockOut=Instance.new(“ObjectValue”)
KnockOut.Name=“KnockOut”
KnockOut.Value=Character
KnockOut.Parent=TargetHumanoid.Parent
Debris:AddItem(KnockOut, 5)
end

Use that function to tag the humanoid when they are hit this needs to be done on the serverside.
Then when the player touches the ringout boundary use this code referrring to the boundary.
local Boundary=script.Parent

Boundary.Touched:Connect(function(hit) if hit.Parent:FindFirstChild(“KnockOut”) then
Boundary.CanTouch=false
local Player=game.Players:GetPlayerFromCharacter(hit.Parent:KnockOut.Value)
Player.leaderstats.KOs.Value= Player.leaderstats.KOs.Value+1
repeat if hit.Parent:FindFirstChild(“KnockOut”)~=nil then
hit.Parent:FindFirstChild(“KnockOut”):Destroy() end
until hit.Parent:FindFirstChild(“KnockOut”)==nil
task.wait()
Boundary.CanTouch=true
end

end end)

1 Like

i kinda did this it def helped me but I used a event to see when the humanoid died then find the knockout value and get the player from char and then add a point to the player

1 Like

Sounds like you did pretty much got it down congrats! But I would still reccomend trying out that code for the ringout! it would be really neat. If you need any help with it let me know.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.