Unfortunately, I can’t tween with models (I don’t know why). So what can I do ?
Script:
local openPart = script.Parent
local door = workspace.Door
local TweenService = game:GetService("TweenService")
local debounce = false
local tweenInfo = TweenInfo.new(
3,
Enum.EasingStyle.Exponential,
Enum.EasingDirection.Out,
0,
false,
0
)
local openDoor = {
CFrame = door.CFrame + Vector3.new(0,0,4.75)
}
local closeDoor = {
CFrame = door.CFrame + Vector3.new(0,0,0)
}
local tween1 = TweenService:Create(door, tweenInfo, openDoor)
local tween2 = TweenService:Create(door, tweenInfo, closeDoor)
openPart.Touched:Connect(function(hit)
if debounce == false and hit.Parent:FindFirstChild("Humanoid") then
tween1:Play()
debounce = true
end
end)
openPart.TouchEnded:Connect(function(hit)
if debounce == true and hit.Parent:FindFirstChild("Humanoid") then
tween2:Play()
debounce = false
end
end)```
The tween is bugging cause youre tweening it in a server script probably. If you want everyone to see the tween use a remore event that fires to all clients. And you can tween models, try welding the parts of the model together and then tween the primary part.
Here is one of my very old scripts I used for a project long ago. It tweens a model ‘Car_1’ or ‘Car_2’, but their parts are welded together, that is very important.
local ts = game:GetService("TweenService")
local car_1 = script.Car_1
local car_2 = script.Car_2
local pointA = workspace.Futuristic_Alley.Backdrop.PointA
local pointB = workspace.Futuristic_Alley.Backdrop.PointB
local pointC = workspace.Futuristic_Alley.Backdrop.PointC
local pointD = workspace.Futuristic_Alley.Backdrop.PointD
local function moveCar(carModel, pointX, pointY)
local car = carModel:Clone()
car.Parent = workspace
car:SetPrimaryPartCFrame(pointX.CFrame)
local randomSpeed = math.random(2 ,4)
local tweenInfo = TweenInfo.new(randomSpeed, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = ts:Create(car.PrimaryPart, tweenInfo, {CFrame = pointY.CFrame})
tween:Play()
tween.Completed:Connect(function()
car:Destroy()
end)
end
local function loopCars()
local randomCar = math.random(1, 2)
local randomTrack = math.random(1, 2)
if randomCar == 1 then
if randomTrack == 1 then
moveCar(car_1, pointA, pointB)
else
moveCar(car_1, pointC, pointD)
end
else
if randomTrack == 1 then
moveCar(car_2, pointA, pointB)
else
moveCar(car_2, pointC, pointD)
end
end
end
while true do
local randomNumber = math.random(1, 3)
loopCars()
wait(randomNumber)
end
Make a primary part for the model. Preferably an invisible part located at the pivot of the model.
Set the primary part anchored to true, then, unanchor and add weld constraints to all other parts linked to the primary part.
Tweening the primary part will now tween all welded parts aswell.