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)

5 comments
You need to fill out all the vector3 values, right now you only have one
also you need to play the tween, with :Play()
also also you need to secify which attribute you are tweening (Ex. {Position = Cams.Position.X + Vector3.new(50, 50, 50)})
Sorry for being AFK for so long! I will try this right away.
Hi there, I'm still having issues. I am still getting the same error message "Vector3 expected, got number"