Mouse trailer constant ? Any ideas

Hello there, I’m trying to make a game, in where I would need to make a trailer for the mouse would that be possible keep in mind I want it constant, since all of the tries I had weren’t and they were pretty bad making you get a headache!
image
image this it’s one of the tries!

1 Like

Use the mouse to move a 3D part in front of the camera that has a trail. You can calculate where to put it with the camera CFrame.

Something like this?

Yeah, I think that’s what he’s talking about

Cool, I just made a script about it when I saw this topic. I guess I’ll post it here later.

1 Like

this it’s pretty good to be honest

Thank you! <3

This is the script I used in a ScreenGui, with IgnoreGuiInset set to true;

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")

local previous_mousePosition = nil

local beamDuration = 0.1

local function Make_Trail_Frame(Point1,Point2)
	local Position1,Position2 = UDim2.fromOffset(Point1.X,Point1.Y),UDim2.fromOffset(Point2.X,Point2.Y)
	local Trail = Instance.new("Frame")
	Trail.BorderSizePixel = 0
	Trail.BackgroundColor3 = Color3.new(1,1,1)
	Trail.Parent = script.Parent
	Trail.AnchorPoint = Vector2.new(0.5,0.5)
	
	Trail.Position = Position1:Lerp(Position2,0.5)
	Trail.Size = UDim2.fromOffset((Point1-Point2).Magnitude,5)
	Trail.Rotation = math.deg(math.atan2((Point1-Point2).Y,(Point1-Point2).X))
	
	return Trail
end

local function Tween(object,duration,goal)
	TweenService:Create(object,TweenInfo.new(duration),goal):Play()
end

RunService.RenderStepped:Connect(function()
	if previous_mousePosition == nil then previous_mousePosition = UserInputService:GetMouseLocation() return end
	
	local mousePosition = UserInputService:GetMouseLocation()
	local Trail = Make_Trail_Frame(mousePosition,previous_mousePosition)
	Tween(Trail,beamDuration,{BackgroundTransparency = 1,Size = UDim2.fromOffset((mousePosition-previous_mousePosition).Magnitude,0),BackgroundColor3 = Color3.fromRGB(0,0,0)})
	Debris:AddItem(Trail,beamDuration)
	
	previous_mousePosition = mousePosition
end)

Thank you so much for it ! It matches whatt I wanted pretty good

You can even increase the width the faster it’s moving, using the mouse delta.

Great, please mark my post as the solution so people know what solved this topic!

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