Tweening/Smooth move moving item

Hello Devforum, I’m trying to make this trailer support move up and down smoothly, but I can’t seem to get it to work. (Probably because it has to be unanchored)

How would I go on about doing this?

Here’s my code:

local ts = game:GetService("TweenService")

local foot = script.Parent.Foot
local FootDown = script.Parent.FootDown
local FootUp = script.Parent.FootUp
local handle = script.Parent.Handle.Handle

local Up = true

local tweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)



local DownGoals = {
	Position = FootDown.Position
}

local UpGoals = {
	Position = FootUp.Position
}

handle.ClickDetector.MouseClick:Connect(function()
	handle.ClickDetector.MaxActivationDistance = 0
	if Up == true then
		local DownTween = ts:Create(foot, tweenInfo, FootDown.Position)
		DownTween:Play()
		Up = false
	else
		local UpTween = ts:Create(foot, tweenInfo, FootUp.Position)
		UpTween:Play()
		Up = true
	end
	wait(5)
	handle.ClickDetector.MaxActivationDistance = 32
end)

Replace this:

With this:

{Position = FootUp.Position}

(For both the DownTween and the UpTween)

2 Likes

Try this:

local ts = game:GetService("TweenService")

local foot = script.Parent.Foot
local FootDown = script.Parent.FootDown
local FootUp = script.Parent.FootUp
local handle = script.Parent.Handle.Handle

local Up = true

local tweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local DownGoals = {
	Position = FootDown.Position
}

local UpGoals = {
	Position = FootUp.Position
}

handle.ClickDetector.MouseClick:Connect(function()
	handle.ClickDetector.MaxActivationDistance = 0
	if Up == true then
		local DownTween = ts:Create(foot, tweenInfo, DownGoals)
		DownTween:Play()
		Up = false
	else
		local UpTween = ts:Create(foot, tweenInfo, UpGoals)
		UpTween:Play()
		Up = true
	end
	wait(5)
	handle.ClickDetector.MaxActivationDistance = 32
end)
3 Likes

Looks like the exact same script, can’t really tell, however,
image
I get this whenever I try it.

1 Like
local DownTween = ts:Create(foot, tweenInfo, {Position = FootUp.Position})

Basically this is the same thing that @Mortai_Yt (and I) changed but it’s not saved in a variable (so it might not give you the “unable to cast to dictionary” error).

1 Like

I fixed the script, it should work now:

local ts = game:GetService("TweenService")

local foot = script.Parent.Foot
local FootDown = script.Parent.FootDown
local FootUp = script.Parent.FootUp
local handle = script.Parent.Handle.Handle

local Up = true

local tweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local DownGoals = {
	['Position'] = FootDown.Position
}

local UpGoals = {
	['Position'] = FootUp.Position
}

handle.ClickDetector.MouseClick:Connect(function()
	handle.ClickDetector.MaxActivationDistance = 0
	if Up == true then
		local DownTween = ts:Create(foot, tweenInfo, DownGoals)
		DownTween:Play()
		Up = false
	else
		local UpTween = ts:Create(foot, tweenInfo, UpGoals)
		UpTween:Play()
		Up = true
	end
	wait(5)
	handle.ClickDetector.MaxActivationDistance = 32
end)
3 Likes

This works, however, It goes to the place where the FootUp/Down was in studio, and not where it is running ingame, is there also a way to do this?

1 Like

Does your FootUp part move around?
Then you might have to put it in a loop.

Also, to explain why your script does not work, you have to put it in a table containing the end values of the properties.

1 Like

Yes, It is welded to the Base of the support.
But I might make it differently since I didn’t expect it to be such a pain.
Thank you for the effort though.

1 Like