FindFirstChild is not a valid member of Vector3

local Humanoid = script.Parent:WaitForChild("Humanoid")

local Ragdoll = require(game:GetService("ServerScriptService").Hit.RagdollModule)
local Knockback = require(game:GetService("ServerScriptService").Hit.KnockbackModule)

local Table = {}

Humanoid.Touched:Connect(function(Hit)
	if table.find(Table,script.Parent) then return end
	local Bool = Hit:FindFirstChild("HIT_")
	if Bool ~= nil and Bool.Value == true then
		table.insert(Table, script.Parent)
		Ragdoll.Start(script.Parent)
		Knockback.Start(script.Parent, (script.Parent.HumanoidRootPart.Position - Hit.Position).Unit * Vector3.new(200,0,200) + Vector3.new(0,100,0))
		task.wait(5)
		table.remove(Table,script.Parent)
		Ragdoll.Stop(script.Parent)
	end
end)
local knockback = {}

function knockback:Start(Character, direction)
	local HRP = Character:FindFirstChild("HumanoidRootPart")
	if HRP == nil then return end
	
	local Attachment = Instance.new("Attachment")
	Attachment.Parent = HRP
	local LinearVelocity = Instance.new("LinearVelocity")
	LinearVelocity.Parent = Attachment
	LinearVelocity.MaxForce = 9999999
	LinearVelocity.VectorVelocity = direction
	LinearVelocity.Attachment0 = Attachment
	game:GetService("Debris"):AddItem(Attachment,0.1)
end

return knockback

this line is causing a error that i dont know how to fix.
local HRP = Character:FindFirstChild("HumanoidRootPart")

That’s because you’re calling a function that uses self without it. Basically module:function(args) is identical to module.function(module, args) but even tho you’re using . instead of : you aren’t passing it in. So what the function is doing is that it thinks self is script.Parent, Character is your directional Vector, and direction is nil(basically the arguments are offseted).

Two fixes for it:

Knockback:Start(script.Parent, yourVector)
--or
Knockback.Start(Knockback, script.Parent, yourVector)
2 Likes

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