Getting Vector3 expected, got Instance error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to be able to make a gun that shoots blocks from the muzzle.

  1. What is the issue? Include screenshots / videos if possible!

It keeps giving me this error:

Here is the local script that is inside the tool:

local mouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService('ReplicatedStorage')
local Event = rs:WaitForChild('Shoot')

script.Parent.Activated:Connect(function()
	print(mouse.Hit.Position)
	Event:FireServer(mouse.Hit.Position, script.Parent.Handle.Muzzle.WorldPosition)
end)

And here is the server script, where it errors.

-- Variables

local rs = game:GetService('ReplicatedStorage')
local Event = rs:WaitForChild('Shoot')

-- event thing

Event.OnServerEvent:Connect(function(mouse, nozzle)
	local turret = Instance.new("Part")
	turret.BrickColor = BrickColor.Black()
	turret.Shape = Enum.PartType.Ball
	turret.Size = Vector3.new(1,1,1)
	turret.Parent = workspace
	turret.CFrame = CFrame.new(nozzle, mouse) -- It gives me the error here.
	turret.Velocity = turret.CFrame.LookVector * 300
end)

If anyone could tell me the issue it would mean a lot!

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes I looked for help.

when you fire an event the first argument is the player

.OnServerEvent passes the player as the first argument, so instead of mouse, nozzle it should be player, mouse, nozzle

2 Likes

thank you so much, it works now!