Tunnells
(PlaySage)
April 15, 2021, 1:53pm
#1
So i want to tween a model 30 studs in the sky but this code doesnt work.
wait(5)
local Workspaces = game:GetService("Workspace")
local TweenService = game:GetService("TweenService")
local TweeningInformation = TweenInfo.new(
15,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
local function tweenModel(model, CF)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = TweenService:Create(CFrameValue, TweeningInformation, {Value = CF})
tween:Play()
tween.Completed:connect(function()
CFrameValue:Destroy()
end)
end
local function tweenModelPos(model, Pos)
local CF = CFrame.new(Pos) * (model:GetPrimaryPartCFrame() - model:GetPrimaryPartCFrame().p)
tweenModel(model, CF)
end
tweenModelPos(Workspaces.Spin + Vector3.new(0,30,0))
error
17:48:37.666 Workspace.Spin.Script:35: invalid argument #1 (Vector3 expected, got Instance) - Server - Script:35
tweenModelPos(Workspaces.Spin + Vector3.new(0,30,0))
Is that plus supposed to be a comma?
Tunnells
(PlaySage)
April 15, 2021, 2:04pm
#3
I want it too move 30 studs up not to that position
The arguments are still wrong then, it takes two values and you are giving it one. I think this is what you want.
Workspaces.Spin, Workspaces.Spin:GetModelCFrame()+Vector3.new(0,30,0)
Tunnells
(PlaySage)
April 15, 2021, 2:11pm
#5
18:07:48.839 Workspace.Visuals.Effects.Jet.Script:29: invalid argument #1 to ‘new’ (Vector3 expected, got CFrame) - Server - Script:29
This was extremely close to the answer, so if this works for you I suggest that you mark the Jarod’s as correct. The actual thing you want to do is
Workspaces.Spin, Workspaces.Spin:GetModelCFrame().p + Vector3.new(0,30,0)
1 Like
For your information, when you define your TweenInfo:
Tunnells:
local TweeningInformation = TweenInfo.new(
15,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
false,
0
)
…due to the way that TweenInfo.new defaults its values if not explicitly provided any, you can remove all of the arguments aside from the duration. The EasingStyle always defaults to Quad, the EasingDirection always defaults to Out and the last 3 I haven’t ever needed to use/define.
So, instead you could simple write:
local TweeningInformation = TweenInfo.new (15)