Advertisement
Previized

MoveModel Code

Dec 26th, 2020
5,423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. --// You can tweak these setting below !
  2. local tweenService = game:GetService("TweenService")
  3. local tweenInfo = TweenInfo.new(
  4.     10, -- Time to get to destination
  5.     Enum.EasingStyle.Exponential, -- EasingStyle
  6.     Enum.EasingDirection.InOut, -- EasingDirection
  7.     0, -- RepeatCount (when less than zero the tween will loop indefinitely)
  8.     false, -- Reverses (tween will reverse once reaching it's goal)
  9.     0 -- DelayTime
  10. )
  11.  
  12. --// ..But don't mess with anything below !
  13. local function tweenModel(model, CF)
  14.     local CFrameValue =  Instance.new("CFrameValue")
  15.     CFrameValue.Value = model:GetPrimaryPartCFrame()
  16.  
  17.     CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
  18.         model:SetPrimaryPartCFrame(CFrameValue.Value)
  19.     end)
  20.  
  21.     local tween = tweenService:Create(CFrameValue, tweenInfo, {Value = CF})
  22.     tween:Play()
  23.  
  24.     tween.Completed:connect(function()
  25.         CFrameValue:Destroy()
  26.     end)
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement