Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to use SetPrimaryPartCFrame with TweenService?

I would like make that my Model moves with TweenService, but is it possible?

local TweenService = game:GetService('TweenService')

2 comments

0

test it

0

@incapaz, If you got nothing smart to say then say nothing, otherwise if i asked the question, it's because i've already tried it. Thanks dude:)

1 answer

✓ Accepted answer

You would need to do something along these lines, however keep in mind that using SetPrimaryPartCFrame will cause floating point precision errors over time.

local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()

local function tweenModel(model, CF)
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()

	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	
	local tween = tweenService:Create(CFrameValue, info, {Value = CF})
	tween:Play()
	
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
	end)
end

1 comment

0

Do you guys have a way more proper to use the TweenService function to move a model around? if not thanks for your answer!:))

This discussion is preserved as it was. New answers, comments, and votes are closed.