Vector3 expected, got Instance

You could send it as a GIF, MP4, or Mov file

But this is unrelated to the main topic

I am trying to share a video on what is happening, because the issue is really weird.

Basically, when I first spawn in, the bullets spawn at the gun’s barrel, once I move to a different spot, the bullet still fires at the same spot as before, even though I moved the gun’s barrel to a different spot.

Is velocity a vector? Or is it a number?

It’s a number (this is here to extend character length so I can post reply)

What I think is going on here, is your setting the current cframe of the bullet equal to it’s own cframe, times *= CFrame.new(0,0 -velocity * (dt * 60)). Then, the next frame, you set it to it’s own cframe times *= CFrame.new(0,0 -velocity * (dt * 60)). If that runs every frame, then the bullet is going to go insanely fast.

I don’t think that causes the issue right now, but I did notice that the bullet goes very fast. The issue I am experiencing is this:

Also how can I fix the issue you pointed out?

It is pretty much deprecated (it says it exists only for the sake of backwards compatibility)

Do I do what I said I could, or should I figure out a better idea to update the bullet spawning position?

I did a quick check, and the bullet doesn’t spawn where the barrel is, also please go look at the topic that I linked literally at the top of this topic to get a reference of what I am trying to do, only if you haven’t already.

I am also trying to figure out a logic statement to adjust the position of the bullet, but I can’t when the bullet spawns at the center of your screen.

Looking at the tutorial, did you mean to multiply the Z Vector by dt multiplied by 60…?

image

Bullet.CFrame = CFrame.new(0, 0, -velocity * dt)

Not sure what you mean by this, the position will change every frame the RenderStepped event is called?

The bullet moves fine no need to change that, just the bullet spawns in one place, and it’s not even the first position of the barrel, it just spawns at the center of your screen, then moves like normal. When I move, the bullet still spawns in that same position, I can’t make an if statement if the bullet never touches the barrel, so I am kind of stumped.

(Replying to this a day later whoops)

So the error lies in these instances then when the Bullet is first cast:

    --GunBarrel is 1 of the GunComponets that I'm assuming is a BasePart
	local Bullet = Instance.new("Part")
	Bullet.Size = Vector3.new(1,1,5)
	Bullet.Anchored = true
	Bullet.CanCollide = false
	Bullet.Color = Color3.new(255,255,255)
	Bullet.Material = Enum.Material.Neon
	Bullet.Parent = workspace
	--Bullet.CFrame = CFrame.new(GunBarrel.Position, endposition)
    Bullet.Position = Vector3.new(math.random(-50, 50), 5, math.random(-50, 50))

What about try setting the Bullet’s Position relative a random position?

we can see the second argument is ‘endposition’, try endposition.Position.

We’ve already established that there was a Mouse Instance being passed over to the module, so I changed that to Mouse.Hit.Position for the Module Script to detect for assigning the endPosition variable

The new issue here is that once 1 bullet spawns in, any others would stay in that same place and wouldn’t change position

After talking to the creator of the framework, I fixed most of the issues, and now the bullet kind of spawn in. It spawns at the center of the screen, and is normal and works, until you shoot down, once you do that the angles break completely. The bullet still doesn’t spawn at the barrel.

Did you try using math.random() to check if the bullet will spawn in random directions?

I just did, sorry for the late reply, I was working on another game.

you did mistake, where i told /\

Did it like this.

game:GetService("RunService").Heartbeat:Connect(function(dt)
	if IsPlayerHoldingMouse then
		if CanFire then
			CanFire = false
			
			MainModule.cast(GunModel, game.Players.LocalPlayer:GetMouse().Hit.p, 60) --Now script sends mouse.Hit.Position.
			
			wait(FireDelay)
			CanFire = true
		end
	end
end)

I understood that you already fixed that thing, good luck with project.

I just tried your method, and I got a little syntax error:
Screenshot 2021-05-07 171758

The [ after GunModel has red line under it.

No, i said that you already fixed, don’t use mine thing. Read last lines of my reply

1 Like