Tween glitching down

ok so my ■■■■■■■■ tween thing is glitching out and its like going down then gliding up
https://gyazo.com/171d22007ca3c64d255eff2a79903808

wait(6)
local tweenService = game:GetService("TweenService")

local part = script.Parent

local tweeningInformation = TweenInfo.new(

	1,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In 
)


local Tween = tweenService:Create(part,tweeningInformation,{CFrame = workspace.Map.a0.Waypoints.last.CFrame})

part.Anchored = false
Tween:Play()

script.Parent.Touched:Connect(function(hit)
	if hit.Name == "first" or hit.Name == "last" or hit.Name == "middle" then
		if hit:FindFirstChild("WeldConstraint") ~= nil then
			print("hi")
			
			local distance = (hit.WeldConstraint.Part0.Position - hit.WeldConstraint.Part1.Position).Magnitude
			local speed = 0.1
			local tweentimelength = speed * distance

			local tweeningInformation = TweenInfo.new(

				1,
				Enum.EasingStyle.Linear,
				Enum.EasingDirection.In
			)


			local Tween = tweenService:Create(part,tweeningInformation,{CFrame = CFrame.new(hit.WeldConstraint.Part1.Position)})
			
			Tween:Play()
			
		end
	end
	
	if hit.Name == "first" or hit.Name == "last" or hit.Name == "middle" then
		if hit:FindFirstChild("WeldConstraint") == nil then
			script.Parent:Destroy()
			print("yo")
		end
	end

	
end)

its everything in the first if statement that is broken

1 Like

You may want to start by adding some print statements to see what values are being passed into the TweenService. This will give you a better idea of what’s going wrong and help you debug the issue. Additionally, you may want to check if the objects you are trying to manipulate (e.g., “part,” “hit,” etc.) exist and have the properties you expect before trying to use them.

1 Like

aight boiiiiiiiiiiiiiiiiiiiiiiii

1 Like

ive found out everytime it goes for a different waypoint it goes even more down so for example waypoint 1 its 13 studs down and waypoint 2 its 14 studs down

1 Like

everything be running good if you wanted to know

1 Like

This could be happening because the code sets the part’s CFrame property directly to the position of the waypoint without considering the current position of the part. To make the part move smoothly between waypoints, you’ll want to calculate the difference between the current position and the target position, and use that information to set the end position of the Tween. Here’s an example of how you could modify your code to work this:

script.Parent.Touched:Connect(function(hit)
	if hit.Name == "first" or hit.Name == "last" or hit.Name == "middle" then
		if hit:FindFirstChild("WeldConstraint") ~= nil then
			print("hi")
			
			local distance = (hit.WeldConstraint.Part0.Position - hit.WeldConstraint.Part1.Position).Magnitude
			local speed = 0.1
			local tweentimelength = speed * distance

			local tweeningInformation = TweenInfo.new(
				tweentimelength,
				Enum.EasingStyle.Linear,
				Enum.EasingDirection.In
			)

			local startPosition = part.CFrame.p
			local endPosition = hit.WeldConstraint.Part1.Position
			
			local Tween = tweenService:Create(part,tweeningInformation,{CFrame = CFrame.new(startPosition, endPosition)})
			
			Tween:Play()
			
		end
	end
	
	if hit.Name == "first" or hit.Name == "last" or hit.Name == "middle" then
		if hit:FindFirstChild("WeldConstraint") == nil then
			script.Parent:Destroy()
			print("yo")
		end
	end
end)
1 Like

and startposition being the parts position right and end position being the waypoint right (it didnt work)

1 Like

Yep that’s right, By setting the CFrame property of the Tween to a new CFrame created with the startPosition and endPosition , the part will move smoothly from its current position to the position of the waypoint over the course of the Tween.

1 Like

Can you post more info about what exactly is happening, or what error message you’re receiving, if any?

1 Like

it works even worse that way no offense would you like me to create a gyazo

1 Like

https://gyazo.com/e3dc6f883f8bd70bde5ee778a2a9f088

1 Like

There seems to be a problem where the part moves further down each time it moves to a new waypoint. This could be due to the fact that the code sets the part’s CFrame property directly to the position of the waypoint without considering the current position of the part.

1 Like

u already said that and i have 0 clue what do to

1 Like

I have got no idea too, lmao. Edit: Yea IDK.

??? the hell is a value error lmao