Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a tween my script no work?

Asked by 3 years ago

so im trying to tween the camera towards another part when you click a gui but it isnt working i think the problem is with the tween creation

my script:

local TweenService = game:GetService("TweenService")
local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Position = UDim2.new(-3, 0, 0.5, 0)
local cam = game.Workspace.CurrentCamera
local FocusPart = game.Workspace.CamPart2
TweenInfo.new (3.0,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,  0,false,  0 )


wait(7)

object:TweenPosition(UDim2.new(0.5, 0, 
 0.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back)

local function onActivated()    --part that isn't working

    cam.CameraSubject = FocusPart
    cam.CameraType = Enum.CameraType.Scriptable

    local tween = TweenService:Create(cam,TweenInfo,{CFrame = FocusPart.CFrame}  )
tween:Play()

end
object.Activated:Connect(onActivated)

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

TweenInfo is an enum not a setting

local TweenService = game:GetService("TweenService")
local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Position = UDim2.new(-3, 0, 0.5, 0)
local cam = game.Workspace.CurrentCamera
local FocusPart = game.Workspace.CamPart2
local Info = TweenInfo.new (3.0,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,  0,false,  0 )

wait(7)

object:TweenPosition(UDim2.new(0.5, 0, 
 0.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back)

local function onActivated()

    cam.CameraSubject = FocusPart
    repeat
         cam.CameraType = Enum.CameraType.Scriptable
    until cam.CameraType == Enum.CameraType.Scriptable

    local tween = TweenService:Create(cam,Info,{CFrame = FocusPart.CFrame}  )
tween:Play()

end
object.Activated:Connect(onActivated)
0
thx took a while to accept it as a answer because roblox was down and stuff rabidazara 6 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Make sure it's in a local script, not in a serverscript.

0
yes i did rabidazara 6 — 3y

Answer this question