Weld causing lag, alternetive?

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.

3 Likes

try destroying every weld after it has been used

1 Like

This already happens in another part of the script.

2 Likes

Maybe weld constraints?

1 Like

Tried using those also, same issue.

1 Like

Sorry, no idea then I’ve never had issues with welds. Try chat GBT or the Roblox assistance.

1 Like

Solved!

the solution was pretty hacky but I used RigidConstraints with attachments on both parts and actively moved the attachment rather than the part.

1 Like

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