I’m making a tower defense game, and the placement system isn’t that smooth, so I wanted to implement TweenService to fix that.
The towers are models, and have player rigs. When I try to tween the models, only the PrimaryPart (The head) moves. This is the script I am using:
local tween = tweenservice:Create(tower.PrimaryPart, tweenInfo, {CFrame = CFrame.new(mouse.Hit.p * CFrame.fromEulerAngles(0,0,0)})
tween:Play()
Using the PrimaryPart only moves the PrimaryPart. I’ve tried anchoring the whole model, but this didn’t work.
Any help is appreciated. Many Thanks.
Here, I think this will help:
BEFORE BUMPING: THE WELD METHOD HAS ALREADY BEEN SHARED. (07.11.2022) There’s been a few times where new posts have mentioned a method already posted, especially the weld method. Please see the edit below which has a link to a tutorial on tweening models or post #2 for a summary of how to perform the method!
EDIT: I see this post is still getting linked. Please use the new method I’ve devised and posted on Community Tutorials as opposed to this. It is available here . Solution has been changed f…
Good luck with your game!
You cannot directly use TweenService on a model, but what you can do is tween the primary part.
I know you said that it will only move the primary part but to fix this all you need to do is weld everything together. You can do this by using this very user-friendly plugin called “RigEdit Lite.” https://create.roblox.com/marketplace/asset/1274343708/RigEdit-Lite%3Fkeyword=&pageNumber=&pagePosition=
wait my bad, wrong link, this one should be the right one:
Edit (06/30/2021): Due to the release of the new pivot APIs and the thankful deprecation of SetPrimaryPartCFrame, the legacy method of CFraming is now also appropriate and you do not necessarily need to use this welding method. Do note that the pivot CFrame is different from the PrimaryPart CFrame though, so you will have to account for that when writing your proxy objects.
Edit (05/31/2023): Roblox has an official code sample for model tweening! It’s very lightweight and covers the necessities…
If I do that, it would affect the tower after it’s placed aswell, and I’m afraid that it might not be able to move/be animated afterwards. Everything in the rig is connected by Motor6D’s aswell, but I’m not sure if that would work the same.
If you are afraid of animations / movement, then you can use Motor6Ds and I think it will serve the same purpose.
s7eely
(eric)
December 30, 2023, 12:11am
#7
You can’t tween models.
What you can do is set a PrimaryPart for the model, weld all the other parts of the model to that part, and tween the PrimaryPart.