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

How am I supposed to do this part tween in a local script?

I'm trying to tween a part do a different place & rotation, this is the whole script that I've made:

script.Parent.MouseEnter:Connect(function()
	local object = script.Parent
    object:TweenSize(UDim2.new(0, 430, 0, 85), nil, nil, 0.1)
end)

script.Parent.MouseLeave:Connect(function()
	local object = script.Parent
    object:TweenSize(UDim2.new(0, 400, 0, 80), nil, nil, 0.1)
end)

script.Parent.MouseButton1Click:Connect(function()
	local object2 = script.Parent
    object2:TweenPosition(UDim2.new(0.5, 0, 1.5, 0))
    local object3 = script.Parent.Parent.AboutButton
    object3:TweenPosition(UDim2.new(0.5, 0, 1.5, 0))

    local tweenService = game:GetService("TweenService")
    local part = game.Workspace.CameraPart

    local tweeningInformation = TweenInfo.new(

    5,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.In,
    0,
    false
    )

    local partProperties = {
	
	    Position = Vector3.new(20.7,8,17.14);
	    Orientation = Vector3.new(0,90,0)

    }
    
    local Tween = tweenService:Create(part,tweeningInformation,partProperties)
    Tween:Play()
end)

It's a local script, and I've tried using a remote event to do the part tween, but nothing! Can someone help me? The actual code is line 16 downwards.

1 answer

✓ Accepted answer

Try using CFrame instead of Position and Orientation.

script.Parent.MouseButton1Click:Connect(function()
    local tweenService = game:GetService("TweenService")
    local part = workspace.CameraPart

    local tweeningInformation = TweenInfo.new(

   	 5,
   	 Enum.EasingStyle.Quad,
   	 Enum.EasingDirection.In,
   	 0,
   	 false
    )

    local partProperties = {
	CFrame = CFrame.new(20.7,8,17.14) * CFrame.Angles(0, math.rad(90), 0)
	}

    local Tween = tweenService:Create(part, tweeningInformation, partProperties)
    Tween:Play()
end)

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