How to visualize bullets on the client?

I’m making a gun system (for PvE) and I want to visualize my bullets on everyone’s client, how can I do this? I’m unsure of where to get started, this is my current code:

local function fireBullet(mousePosition: Vector3)
	local origin = firePoint.WorldPosition
	local vectorDirection = (mousePosition - origin).Unit * Configuration.bulletRange
	local raycastResult = Workspace:Raycast(origin, vectorDirection, raycastParams)
	
	local intersection = raycastResult and raycastResult.Position or origin + vectorDirection
	local distance = (origin - intersection).Magnitude
	
-- BULLET VISUALIZING PROCESS BELOW --
	local cosmeticBullet = cosmeticBulletTemplate:Clone()
	cosmeticBullet.Size = Vector3.new(0.1, 0.1, distance)
	cosmeticBullet.CFrame = CFrame.lookAt(origin, intersection) *  CFrame.new(0, 0, -distance/2)
	cosmeticBullet.Parent = Workspace
	task.delay(.25, function()
		cosmeticBullet:Destroy()
	end)
end

I was thinking when the raycast fires, I send a remoteEvent to all clients with the necessary info for the bullet’s position, size, etc. Then each client creates the bullet on their side using the info that was sent to it. Would this method work or do I have to do something else? Are there any bugs that could happen with this?

If you want to make it visible to other clients, you’ll need to make it visible to the server first. This allows other clients to see it. You can achieve this by using a RemoteEvent and firing it from the client to the server

What im trying to do is instead of visualizing the bullet on the server, the data from the server will be sent to each client so they can visualize the bullet. My current script works on the server. Sorry for not making that clear

then why not just create a tracer on the server? visible to everyone

no need for :FireAllClients()

I heard that the client should handle the visuals, not the server. I already figured out a way to do this, sorry for the confusion.

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