I need to have a snowball attatched to a player and the size and distance increasing over time, but it causing insane lag points.
This is my function:
local function linkBallToPlayer(ball, plr)
local root = plr.Character.PrimaryPart
local weld = Instance.new("Weld")
weld.Parent = ball
weld.Part0 = ball
weld.Part1 = root
task.spawn(function()
while task.wait(1) do
ball.Size = Vector3.new((plr.leaderstats.Snow.Value/10)+1,(plr.leaderstats.Snow.Value/10)+1,(plr.leaderstats.Snow.Value/10)+1)
-- Problem line:
ball.Position = Vector3.new((root.Position + (root.CFrame.LookVector * (root.Size.Z / 2 + plr.leaderstats.Snow.Value/20 + root.Size.Z / 2))).X, plr.leaderstats.Snow.Value/20+.35, (root.Position + (root.CFrame.LookVector * (root.Size.Z / 2 + plr.leaderstats.Snow.Value/20 + root.Size.Z / 2))).Z)
--
end
end)
end
How could I fix this? I tried using Heartbeats and updating but that caused very snappy behaviour.