I'm trying to make a fe gun but when I try to cframe it this happens script.

game.ReplicatedStorage.Shoot.OnServerEvent:connect(function(player, position)
	local s = require(game.ReplicatedStorage.GunData.FAMAS)
	if workspace[player.Name].Humanoid.Health <=0 then
	else
--		local distance = (workspace.CurrentCamera.FAMAS.FAMAS.Flash.CFrame.p - position).magnitude
		local bullet = Instance.new("Part", workspace.Bullets)
		bullet.CFrame = CFrame.new(workspace.CurrentCamera.FAMAS.FAMAS.Flash.CFrame.p, position) * CFrame.new(0,0,-s.range/2)
		bullet.BrickColor = BrickColor.new("New Yeller")
		bullet.Size = Vector3.new(0.2,0.2,0.2)
		bullet.Material = "Neon"
		bullet.Name = "Bullet"
		bullet.Anchored = false
		bullet.CanCollide = false
		bullet.Locked = true
	end
end)

Error

12:41:11.085 - ServerScriptService.Event:7: bad argument #2 to 'new' (Vector3 expected, got Object)

Can someone help :()

7 comments

0

What type does  the variable "position" hold?

0

line 7, change cframe to vector

0

Try doing vector3.new instead of CFrame.new

0

yea i did that but then another error came in i forgot what it was my pc died sorry.

0

and the position thing i actually don't know i was using a tutorial on youtube by Alvin Blox but i want my bullet to have velocity and realism but of course it doesn't work.

0

Whats the variable "position" actually hold???????

0

well i don't remember defining the variable because this is the server script side . I don't know what to do i'm lost,