I have a long strand of parts that for now is linked to your torso and moves according to the song played (audio visualizer thing) but I wanted to change it so instead it moved each block (still in a line) to your mouse
for i = 1, #Parts2 do if i == 1 then Parts2[i].CFrame = Parts2[i].CFrame:lerp(game.Players.LocalPlayer.Character.Torso.CFrame+Vector3.new(0,.75,0), 0.9) else Parts2[i].CFrame = Parts2[i].CFrame:lerp(Parts2[i - 1].CFrame * CFrame.Angles(-loudness / 10, math.sin(-loudness / 1000000000), 0) * CFrame.new(0, 0, 0.15), 0.8) end end
Thats my current code, if you could help me with having it lerp to my mouse it would be great.
You could use the MouseMoved
event to detect when the mouse moves, and then group the parts in a model and use the SetPrimaryPartCFrame
function to move them.
Note: Remeber to use variables to keep your code clean and organised.
local plr = game.Players.LocalPlayer local m = plr:GetMouse() local parts --This is your model of the parts. repeat wait() until plr.Character local char = plr.Character local tor = char:WaitForChild("Torso") local offset = CFrame.Angles(-loudness / 10, math.sin(-loudness / 1000000000), 0) function visualize() for i = 1, #Parts2 do if i == 1 then Parts2[i].CFrame = Parts2[i].CFrame:lerp( tor.CFrame+Vector3.new(0,.75,0), 0.9 ) else Parts2[i].CFrame = Parts2[i].CFrame:lerp( Parts2[i - 1].CFrame * offset * CFrame.new(0, 0, 0.15), 0.8 ) end end end m.MouseMoved:Connect(function() local spot = m.Hit; parts:SetPrimaryPartCFrame(spot) end) while wait(.1) do visualize() end