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

main menu camera not moving when clicking gui?

Asked by 1 year ago

I'm making a main menu in my game where if you click a left or right gui it makes the camera move to a different area,

I got the camera to be placed in the first location just fine but if I try moving it, it does nothing

here is my code, thank you in advance

local tweenService = game:GetService("TweenService")

local zone = 1

-- camera parts

local crossroadsPos = game.Workspace:WaitForChild("crossroadsPos").CFrame
local sfothclassicPos = game.Workspace:WaitForChild("sfothclassicPos").CFrame

local cCamera = game.Workspace.CurrentCamera

local Zones = {crossroadsPos, sfothclassicPos}

-- gui parts

left = script.Parent:WaitForChild("zoneScroll").left
right = script.Parent:WaitForChild("zoneScroll").right

wait()

cCamera.CameraType = Enum.CameraType.Scriptable
cCamera.CFrame = crossroadsPos

local function cameraTween(Point, Speed)
    tweenService:Create(cCamera, TweenInfo.new(Speed, Enum.EasingStyle.Linear), {CFrame = Point.CFrame}):Play()
end

local function leftTrigger()
    if zone == 1 then
        return
    elseif zone >= 2 then
        zone -= 1
        cameraTween(Zones[zone], 1)
    end
end

local function rightTrigger()
    if zone == 2 then
        return
    elseif zone <= 1 then
        zone += 1
        cameraTween(Zones[zone], 1)
    end
end

left.MouseButton1Click:Connect(leftTrigger)
right.MouseButton1Click:Connect(rightTrigger)

Answer this question