Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create a tween my script no work?

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

✓ Accepted answer

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)

1 comment

0

thx took a while to accept it as a answer because roblox was down and stuff

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

1 comment

0

yes i did

This discussion is preserved as it was. New answers, comments, and votes are closed.