Bullet system with LineHandleAdornement

Hello ! I’m currently working on an FPS System, and i came to the bullet part. I wanted to make a bullet that would be a simple yellow line because i don’t want something complictaed that i will not understand. I have to use “LineHandleAdronement” but i don’t know how i can ?
Here is the serverscript (that handles raycasting) :

local RS = game:GetService("ReplicatedStorage");
local Events = RS:WaitForChild("Events")

Events.Fire.OnServerEvent:Connect(function(plr, part, pos, damage, o, op, ocf)	

	
	if part.Parent:FindFirstChild("Humanoid") then
		local humanoid = part.Parent.Humanoid;
		if humanoid.Health > 0 then
			humanoid:TakeDamage(damage);
		end
	else
		local impact = RS:WaitForChild("Objects").Impact:Clone();
		impact.Position = pos
		impact.Parent = workspace
		game.Debris:AddItem(impact, 5);
	end

end)

Thanks !

2 Likes

See: LineHandleAdornment. I think the documentation is sufficient enough to understand what’s going on here. You parent a LineHandleAdornment to a BasePart representing the bullet and extend the length of the line accordingly.

Assuming you’re using LineHandleAdornments to visualise raycasts then probably all you’d need is to calculate the magnitude between the origin and the hit position to find out the length.

1 Like

So i made that in a script but the line is invisible even when putting it parent to the workspace

1 Like

They also do have an Adornee, so make sure to set that. I can’t really help you any further if you’re still encountering issues with bullet visualisation unless you show me the exact code you’re currently using to manage the LineHandleAdornment as well as any related errors, if any.

1 Like

I don’t know what the adornee should be here :

local Line = Instance.new("LineHandleAdornment");
Line.Parent = workspace
Line.Length = (pos - op).magnitude;
Line.Color3 = Color3.fromRGB(243, 255, 0);
Line.CFrame = ocf

“o” is the origin part

1 Like

Both Adornee and Parent (set Parent last rather than right after making it for a little performance boost) should be the bullet part or some place where the adornment can reside in.

1 Like

Thank you its working ! (The problem was to set the adornee to the line parent and not the part where it is shot by)