Unit Dont work, It stays at 0,0,0

So im making shotgun and i want to calculate final posiiton of bullet (see script) but it act weirdly

Problem:

its counting the unit from position 0,0,0 and i want it around player, here is code:

script.Parent.Shoot.OnServerEvent:Connect(function(player, pos, origin)
	for i = 0,8,1 do
		local distanceShoot = (pos - origin).magnitude
		local SpreadPos = pos + Vector3.new(math.random(0 - distanceShoot,distanceShoot)/30,math.random(0 - distanceShoot,distanceShoot)/30,math.random(0 - distanceShoot,distanceShoot)/30)
		local Bullet = game.ReplicatedStorage.Bullet:Clone()
		Bullet.Parent = game.Workspace.GunShoots
		Bullet.Anchored = true
		
		local direction = (SpreadPos - origin).Unit*50
		print(SpreadPos)
		local result = workspace:Raycast(origin, direction)
		
		Bullet.Position = direction
		
		
		
		
		
		
	end
end)

script is server based, pos is mouse position, origin is gun position, the script is not complete

ok i fixed it and works now so itws good

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