So I have been making a mouse trailer with some help from the people here, but I have a huge problem that being when it scales it looks so wierd since I can only make it with squares and not other shapes any ideas ?
Script:
local MouseTrailModule = {}
MouseTrailModule.__index = MouseTrailModulelocal UserInputService = game:GetService(“UserInputService”)
local RunService = game:GetService(“RunService”)
local Debris = game:GetService(“Debris”)
local TweenService = game:GetService(“TweenService”)
local Players = game:GetService(“Players”)–local Trove = require(game.ReplicatedStorage.Packages.Trove)
function MouseTrailModule.new(_beamDuration : number?)
local self = setmetatable({}, MouseTrailModule)–self.Trove = Trove.new()
self.player = Players.LocalPlayer
self.playerGui = self.player:WaitForChild(“PlayerGui”)
self.screenGui = self.playerGui:FindFirstChild(“MouseScreenGui”) or Instance.new(“ScreenGui”,self.playerGui)
self.screenGui.Name = “MouseScreenGui”–self.Trove:Add(self.screenGui,“Destroy”)
self.mouse = self.player:GetMouse()
self.beamDuration = _beamDuration or 0.2
self.previous_mousePosition = nilself.Connection = nil
–self.Trove:Add(self.Connection,“Disconnect”)
return self
endfunction MouseTrailModule:Enable()
local function Tween(object, duration, properties)
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = TweenService:Create(object, tweenInfo, properties)
tween:Play()
endlocal 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(128, 128, 128) – White interior color
Trail.Parent = self.screenGui
Trail.AnchorPoint = Vector2.new(0.5, 0.5)Trail.Position = Position1:Lerp(Position2, 0.5) local length = (Point1 - Point2).Magnitude + 6 local thickness = math.min(20, 5 + (Point1 - Point2).Magnitude / 5 * 20) Trail.Size = UDim2.fromOffset(length, thickness) Trail.Rotation = math.deg(math.atan2((Point1 - Point2).Y, (Point1 - Point2).X)) -- Apply UIGradient for the fade effect local gradient = Instance.new("UIGradient") gradient.Color = ColorSequence.new({ ColorSequenceKeypoint.new(0, Color3.fromRGB(128, 128, 128)), -- White at the edges ColorSequenceKeypoint.new(0.2, Color3.fromRGB(255, 255, 255)), -- Gray in the middle ColorSequenceKeypoint.new(0.8, Color3.fromRGB(255, 255, 255)), -- Gray in the middle ColorSequenceKeypoint.new(1, Color3.fromRGB(128, 128, 128)) -- White at the edges }) gradient.Rotation = 90 -- Adjust if needed to match the orientation of the trail gradient.Parent = Trail local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0.5, 0) -- Make the frame round corner.Parent = Trail return Trail
end
self.Connection = RunService.RenderStepped:Connect(function()
if self.previous_mousePosition == nil then self.previous_mousePosition = UserInputService:GetMouseLocation() return endlocal mousePosition = UserInputService:GetMouseLocation() if mousePosition == self.previous_mousePosition then return end local Trail = Make_Trail_Frame(mousePosition,self.previous_mousePosition) Tween(Trail,self.beamDuration,{Size = UDim2.fromOffset((mousePosition-self.previous_mousePosition).Magnitude,0),BackgroundColor3 = Color3.fromRGB(255, 255, 255)}) ---BackgroundTransparency = 1, Debris:AddItem(Trail,self.beamDuration) -- trb sa pun un romb care se uit in directia in care se misca moseul deci iau pozitia veche cu pozitia actuala si vad orientarea -- trb scalat sa nu fie la fel de mare sa i pun gradient ca la trail self.previous_mousePosition = mousePosition
end)
self.mouse.Icon = “”
endfunction MouseTrailModule:Disable()
if self.Conneciton then
self.Connection:Disconnect()
self.Connection = nil
end
self.mouse.Icon = “rbxasset://SystemCursors/Arrow”
endfunction MouseTrailModule:Destroy()
self:Disable()
–self.Trove:Destroy()
endreturn MouseTrailModule