Tweening Position is extremely glitchy?

Hello,
I’m tweening a part and its phasing through the table and being very glitchy, as the video shows:

External Media

Here’s my code for this. I’m using a placeholder part for now by instancing.

	for i, v in grid do -- per row
		for k, x in grid[i] do -- per column
			if grid[i][k] == 1 then
				local piece = board:FindFirstChild(tostring(i) .. tostring(k))
				if piece then
					local token = Instance.new("Part")
					token.Parent = board
					token.Size = Vector3.new(0.5,0.5,0.5)
					token.Name = "token"
					token.CanCollide = false
					token.CanTouch = false
					token.CanQuery = false
					token.Anchored = false
					
					token.Position = Vector3.new(piece.Position.X, originpoint.Value.Y + spacedistance.Value, originpoint.Value.Z)
					
					local twinfo = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
					local goal = {CFrame = piece.CFrame}
					local tokentween = ts:Create(token, twinfo, goal)
					tokentween:Play()
					task.wait(1)
					token.Position = piece.Position
					token.Anchored = true
					piece:Destroy()
				end
			end
		end
	end

Any help would be greatly appreciated!

1 Like

I’ve noticed that extra “tokens” have been created, which is quite strange. This might be why it looks glitchy…

1 Like

Did some more testing, and it appears that there are 3 tokens on row 6, column 1, 2 tokens on row 6, column 2, and 1 token on row 6, column 3.
There is only meant to be 1 in each of these places.
I doubt that this is the reason this is happening…
Also, half the time the part doesn’t even spawn in :confused:

OK, the reason why the tokens were appearing multiple times is because the bindable event I was using was fired 3 times, 1 for each update, which is why they were distributed in the way they were. To fix this, I fired the event at the end of the full update.
I fixed the part not instancing in too.
This still doesn’t fix the glitchiness.
Changing the twinfo settings doesn’t do anything either…

When Tweening the CFrame of a Part, it’s recommended to Anchor the Part first to stop physics being applied (which is causing the glitching).

token.Anchored = true
1 Like

What a simple solution!
Thanks a lot, it was much easier than I initally thought. I was under the impression that anchoring it would cause the tween to not run.

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