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

[SOLVED] How does one tween a plus value with vector3?

Asked by 3 years ago
Edited 3 years ago

I'm having trouble with creating a camera that moves when pressed a gui button.

Code:

local Tween = game:GetService("TweenService")
local cam = workspace.Camera
local Cams = workspace:WaitForChild("Newcam")
local LocalPlayer = game.Players.LocalPlayer
local Left = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Left
local Right = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Right
local test = game.StarterGui.ScreenGui.test
repeat wait() until cam.CameraSubject ~= nil
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = Cams.CFrame

Right.MouseButton1Click:Connect(function()
    Tween:Create(Cams, TweenInfo.new(2), {Cams.Position.X + Vector3.new(50)}) -- Here is where I'm having trouble.
end)

Edit: I've since found out that the camera script is preventing the block (Cams) from moving. I believe it may be the repeat wait(), but I'm unsure.

Updated Code:

local Tween = game:GetService("TweenService")
local cam = workspace.Camera
local Cams = workspace:WaitForChild("Newcam")
local LocalPlayer = game.Players.LocalPlayer
local Left = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Left
local Right = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Right
local test = game.StarterGui.ScreenGui.test
--repeat wait() until cam.CameraSubject ~= nil
--cam.CameraType = Enum.CameraType.Scriptable
--cam.CFrame = Cams.CFrame

--Found out above camera scripts are blocking the block (Cams) from moving.

Right.MouseButton1Click:Connect(function()
    Tween:Create(Cams, TweenInfo.new(2),{Position = Cams.Position + Vector3.new(-50, 0, 0)}):Play()
end)

Final code:

local Tween = game:GetService("TweenService")
local Camera = workspace.Camera
local NewCamera = workspace:WaitForChild("Newcam")
local LocalPlayer = game.Players.LocalPlayer
local Left = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Left
local Right = LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").Right
repeat wait() until Camera.CameraSubject ~= nil
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = NewCamera.CFrame
Right.MouseButton1Click:Connect(function()
    NewCamera.Position = NewCamera.Position + Vector3.new(-50, 0, 0)
    Tween:Create(Camera, TweenInfo.new(),{CFrame = NewCamera.CFrame}):Play()
end)
Left.MouseButton1Click:Connect(function()
    NewCamera.Position = NewCamera.Position + Vector3.new(50, 0, 0)
    Tween:Create(Camera, TweenInfo.new(),{CFrame = NewCamera.CFrame}):Play()
end)
0
You need to fill out all the vector3 values, right now you only have one Benbebop 1049 — 3y
0
also you need to play the tween, with :Play() Benbebop 1049 — 3y
0
also also you need to secify which attribute you are tweening (Ex. {Position = Cams.Position.X + Vector3.new(50, 50, 50)}) Benbebop 1049 — 3y
0
Sorry for being AFK for so long! I will try this right away. User#40708 0 — 3y
0
Hi there, I'm still having issues. I am still getting the same error message "Vector3 expected, got number" User#40708 0 — 3y

Answer this question