Everything in my script works but EXCEPT for a tween. I’m trying to tween a model and idk if its something with the primary part or what but it won’t work, no error, nothing.
–Here’s The Script
local tool = script.Parent
local EnableAlready = false
local tweenService = game:GetService("TweenService")
local tween1
local function ToolActivated()
if EnableAlready == false then
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
if player then
EnableAlready = true
player.PlayerGui.BuildMenu.Enabled = true
end
end
else
EnableAlready = false
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
player.PlayerGui.BuildMenu.Enabled = false
end
end
end
local option1 = game.StarterGui.BuildMenu.Option1
local MovingTruckProp = game.ReplicatedStorage.MovingTruck
local function Option1Pressed()
if not tween1 then
MovingTruckProp.Parent = game.Workspace
local newCFrame = CFrame.new(tool.Parent.PrimaryPart.CFrame.X, 0, tool.Parent.PrimaryPart.CFrame.Z) * tool.Parent.PrimaryPart.CFrame.Rotation * CFrame.new(0,0,-10)
task.wait()
tween1 = tweenService:Create(MovingTruckProp.PrimaryPart1, TweenInfo.new(7, Enum.EasingStyle.Linear), {
CFrame = newCFrame
})
task.wait(1)
tween1:Play()
end
end
tool.Activated:Connect(ToolActivated)
game.ReplicatedStorage.Option1.OnServerEvent:Connect(Option1Pressed)
You should try using PivotTo() in order to move your model. Pivoting the model should be able to move the PrimaryPart and the rest the model’s parts. To tween the pivoting part, you can tween a CFrame variable and constantly update your model’s position until the tween ends.
Here’s an example:
local newCFrame = CFrame.new(tool.Parent.PrimaryPart.CFrame.X, 0, tool.Parent.PrimaryPart.CFrame.Z) * tool.Parent.PrimaryPart.CFrame.Rotation * CFrame.new(0,0,-10)
local currentCFrame = Instance.new("CFrameValue")
currentCFrame.Value = MovingTruckProp.PrimaryPart1.CFrame -- tween goal
tween1 = tweenService:Create(currentCFrame, TweenInfo.new(7, Enum.EasingStyle.Linear), {
Value = newCFrame
})
task.wait(1)
tween1:Play()
while tween1.PlaybackState == Enum.PlaybackState.Playing do
MovingTruckProp:PivotTo(currentCFrame.Value) -- keeps setting tweening CFrame value
task.wait()
end
currentCFrame:Destroy() -- destroys the CFrame value after
All U need to do is weld the rest of the parts to a main part within the model and tween that! If that doesn’t work try checking you If statements and logic maybe could be a scope issue