Hello. I am currently making a door. This is my first time tweening models instead of just a part. I want to door to move up and it takes two seconds to.
I have the models primary part set to a part called “hinge”. I then welded all the other parts to this part.
Here is my code:
The innerPrimary is the models primary part called hinge.
I set the CFrame.new to the position I want the door to go. When I run it, it does nothing but there are no errors. Can someone help?
I’m pretty sure if it’s Welded to a part, it can’t change position and only orientation. You should separate the tween code and the actual tween playing, and add the script to the Hinge instead (if it’s not added to that). You can also try tweening the Origin Position.
Keep in mind I’m not a professional, it’s just what I think would work. If it doesn’t, I apologize very deeply.
local TpTest = script.Parent
local function move(model, wp)
local TweenService = game:GetService("TweenService")
local TweInfo = TweenInfo.new(
4,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false,
0)
local cf = Instance.new("CFrameValue")
cf.Value = model:GetPrimaryPartCFrame()
cf:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(cf.Value)
end)
local tween = TweenService:Create(cf, TweInfo, { Value = CFrame.new(wp.Position)})
tween:Play()
wait(2)
end
wait(5)
move(TpTest, workspace.Wp) -- set "workspace.Wp" to where you want it to tween to obviously lol
This is caused because “CFrame” is both a class type (custom value type) and a property shared by many instances, so any reference to “CFrame” alone causes a Roblox script to believe that you’re intending to reference the CFrame class/value type as opposed to the property itself, you can avoid this in the same way as I have done in the above by setting the field of the properties table to a string value and enclosing it in a pair of square braces.