Invalid argument #1 to 'new' (Vector3 expected, got nil) - Line 13

Not sure why its asking for vector3, doesn’t vector3 dictate size rather then position?

local rs = game:GetService("ReplicatedStorage")

local stunnedevent = rs:WaitForChild("StunnedEvent")

local HitboxModule = require(rs:WaitForChild("Modules").HitboxModule)

stunnedevent.OnServerEvent:Connect(function(player)
	local hitplayers = HitboxModule.Hitbox(player,CFrame.new(0,0,-2.5),Vector3.new(5,5,5),10)
	local bloodvfx = rs:WaitForChild("M2Vfx"):Clone()
	local chr = player.Character
	local hrp = chr.PrimaryPart
	bloodvfx.Parent = workspace
	bloodvfx.CFrame = CFrame.new(hitplayers.CFrame)
	task.wait(0.5)
	bloodvfx:Destroy()
	
	


	
	
end)
2 Likes

Why are you doing CFrame.new here? You can just do hitplayers.CFrame.

If you want to get the CFrame without the orientation, you can do CFrame.new(hitplayers.Position)


Vector3 is simply a representation of something in 3 axes (typically X,Y,Z). While this could be size, it could also be the position or the orientation!

1 Like

it now says coordinate expected got nil and CFrame expected

1 Like

Reason it’s throwing an error is because hitplayers is nil, so you might need to double-check your HitboxModule.Hitbox function to fix the issue.

1 Like

Can you please post the actual error, plus the code you are now using

– oh yeah, your cframe is also nil anyway.

1 Like

idk where the issue is, could it be the v.Parent

local module = {}

module.Hitbox = function(player,Cframe,Size, Damage)
	local rs = game:GetService("ReplicatedStorage")
	local chr = player.Character
    local hitboxCFrame = chr.PrimaryPart.CFrame * Cframe
    local hitboxSize = Size
    local damage = Damage
    local hitbox = rs.Hitbox:Clone()
    hitbox.Parent = workspace
    hitbox.CFrame = hitboxCFrame
    hitbox.Size = Vector3.new(hitboxSize, hitboxSize, hitboxSize)
    local hitcontent = workspace:GetPartBoundsInBox(hitboxCFrame, hitboxSize)
    local hitlist = {}

    for _,v in pairs(hitcontent) do
	    if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= chr and not table.find(hitlist, v.Parent) then
		table.insert(hitlist, game:GetService("Players"):GetPlayerFromCharacter(v.Parent))
		v.Parent.Humanoid:TakeDamage(damage)
		print(v.Parent.Name)
	    end
	end
	
	return hitlist

end


server script

local rs = game:GetService("ReplicatedStorage")

local stunnedevent = rs:WaitForChild("StunnedEvent")

local HitboxModule = require(rs:WaitForChild("Modules").HitboxModule)

stunnedevent.OnServerEvent:Connect(function(player)
	local hitplayers = HitboxModule.Hitbox(player,CFrame.new(0,0,-2.5),Vector3.new(5,5,5),10)
	local bloodvfx = rs:WaitForChild("M2Vfx"):Clone()
	local chr = player.Character
	local hrp = chr.PrimaryPart
	bloodvfx.Parent = workspace
	bloodvfx.CFrame = hitplayers.CFrame
	task.wait(0.5)
	bloodvfx:Destroy()

	
end)

error
image

1 Like

My guess is that your hitbox isn’t detecting any objects inside of it. To confirm this, paste this code to replace return hitlist in your module:

if #hitlist == 0 then
	print("hitlist is empty!")
else
	print("hitlist isn't empty!")
end

Last question do yk why its dmging players way more then it should, I set the dmg to 10 but its repeating itself

Change this to just V.Parent

1 Like

@sonic_848 already said it, but to explain it further, you were adding the player to the table, but searching for the character rather than player when you did table.find(hitlist, v.Parent). Inserting v.Parent into the table instead should fix the problem.