Stun System not working + Knockback not working

Well, when I decide to make a Stun Global BoolValue, there seems to be no form of stun being used on the thing/player I am hitting. They are still able to actively move.

--Region3 In Action
		local HBFinder = workspace:FindPartsInRegion3(Re3, HitBox, 20)
		Debris:AddItem(HitBox, 0.3)
		for i, parts in pairs (HBFinder) do
			if parts.Parent:FindFirstChild("Humanoid") and parts.Parent ~= Character then
				parts.Parent.Humanoid:TakeDamage(2.5)
				local m1STUNT = Instance.new("BoolValue")
				m1STUNT.Name = "eStun"
				m1STUNT.Parent = Character
				game.Debris:AddItem(m1STUNT,.7)

				if m1STUNT.Parent == parts then
					m1STUNT = true
					local bodyVelocity = Instance.new('BodyVelocity')
					bodyVelocity.Parent = Character.HumanoidRootPart
					bodyVelocity.MaxForce = Vector3.new(0, 0, 0)
					print("Stun locked")
					m1STUNT = false
				end
				break
			end-- If statement ended in forloop
		end--For loop ended
		if Humanoid.Died then
			Humanoid.Died:Connect(function()
				if Humanoid.Died then
					HitBox:Destroy()
					script.Disabled = true
				end--If statement if the humanoid died
			end)--Humanoid died event
		end
	end-- if statement for combat activation on
end--Function End
 


script.Parent.OnServerEvent:Connect(CombatActivation)

It won’t even seem to create a value.

As for the knockback it’s nearly no different. It’s in a different script, but the outcome is still the same

wait(1)
--\\ Services //--

local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")

--\\ Variables //--

local Debounce = false


script.Parent.OnServerEvent:Connect(function(Player, Action, Count)
	
	
	local Character = Player.Character
	local HRP = Character:FindFirstChild("HumanoidRootPart")
	local HumanoidRootPart = Character.HumanoidRootPart
	local HM = Character:FindFirstChild("Humanoid")
	local Humanoid = Character.Humanoid
	local hb = workspace:FindFirstChild("Hitbox")
	
	if Action == ("Combat") and ("KB") then 
		Count = 1
		wait(0.3)
		Count = 2
		wait(0.3)
		Count = 3
		wait(0.3)
		Count = 4
		local PlayerOrientation = Player.Character.HumanoidRootPart.CFrame.LookVector --this will get the orientation that the player is looking at in the world space
		local VelocityModifier = 50 --the higher the number, the higher the velocity 
		local MaxForce = Vector3.new(50000,50000,50000) --higher numbers = more force applied to the player

		for i, parts in pairs(hb) do
			print("Hitbox does indeed exist begin to do dis")
			local bodyVelocity = Instance.new('BodyVelocity')
			bodyVelocity.Parent = parts.Character.Humanoid
			bodyVelocity.MaxForce = MaxForce
			bodyVelocity.P = math.huge -- this makes the bodythrusts P value infinite
			bodyVelocity.Velocity = Vector3.new(-PlayerOrientation.X*VelocityModifier,-PlayerOrientation.Y*VelocityModifier,-PlayerOrientation.Z*VelocityModifier) --make sure to use the inverse of the players orientation, or the player will be knocked forward, rather than backwards
			bodyVelocity.Name = "Bang"
			game.Debris:AddItem(bodyVelocity,0.1) 
		end

	end
end)
1 Like

I can already see a few problems

in your second script, you have ’ local hb = workspace:FindFirstChild(“Hitbox”) ’
but you also have ’ for i, parts in pairs(hb) ’
when hb is defined as a instance and not a table?
if you were trying to go through all children, which is what I assume, then you should
put this before the pairs check: ‘hb = hb and hb:GetChildren() or {}’ or just put ‘hb:GetChildren()’ where you already have hp in the params of the pairs

1 Like

I changed what was in the parameters to be hb:GetChildren{}, which changed nothing really, it still has yet to print out that the script has even began.

1 Like

Fixed this myself. It was a rather of placement in scripts and how it worked. BodyVelocity was useless.

1 Like