local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera local PlayerGui = Player.PlayerGui repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = workspace.CameraPart.CFrame if script.Parent.CameraValue.Value == 1 then PlayerGui.CameraUI.ScreenGuiForward.Enabled = true PlayerGui.CameraUI.ScreenGuiBackward.Enabled = true PlayerGui.CameraUI.ScreenGuiForward2.Enabled = false PlayerGui.CameraUI.ScreenGuiBackward2.Enabled = false end if script.Parent.CameraValue.Value == 2 then PlayerGui.CameraUI.ScreenGuiForward.Enabled = false PlayerGui.CameraUI.ScreenGuiBackward.Enabled = false PlayerGui.CameraUI.ScreenGuiForward2.Enabled = true PlayerGui.CameraUI.ScreenGuiBackward2.Enabled = true end script.Parent.ScreenGuiForward.ForwardBttn.MouseButton1Down:Connect(function() script.Parent.CameraValue.Value = 2 for i = 0,1,0.01 do workspace.CameraPart.CFrame:Lerp(workspace.CameraDestinations.CameraDes2.CFrame, i) wait() end end) script.Parent.ScreenGuiBackward2.BackwardBttn.MouseButton1Down:Connect(function() script.Parent.CameraValue.Value = 1 for i = 0,1,0.01 do workspace.CameraPart.CFrame:Lerp(workspace.CameraDestinations.CameraDes1.CFrame, i) wait() end end)
(This is a local script)
This a script I made for a camera that lerps back and fourth between parts on GUI press.
I'll run over what the code is SUPPOSED to do and what I did. First I have a wait loop for making the camera scriptable. Then, I define the players camera CFrame to the CameraPart's CFrame. I create an if statement of a IntValue I have set up in PlayerGui. If the int value == 1, then the Gui for to the second cam appears and the one lerping to the first disappears. The opposite occurs if the IntValue == 2. I then have a function that lerps the camera to the second destination(The destination is a transparent part). I also have another one that only happens when the backward button that is enabled when the IntValue == 2. This lerps back to the original position, the transparent part CameraDes1. The ForwardGui function also turns the IntValue to 2, and the opposite happens with the other function.
For some reason this does not work at all. All it does is change the IntValue to 2. Even if I hit the backwards button to change it back to one, and the lerping does not work at all. But the camera's CFrame does go to the CFrame of the CameraPart.
Is there something I'm doing wrong? I've searched for days.
Keep in mind I'm a beginner scripter and it might be a glaringly obvious error. I'm sorry if this is the case.
Thank you! :)
Not an actual answer, just simplified code (please ignore this)
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera local PlayerGui = Player.PlayerGui Camera.CameraType = Enum.CameraType.Scriptable Camera.CFrame = workspace.CameraPart.CFrame if script.Parent.CameraValue.Value == 1 then PlayerGui.CameraUI.ScreenGuiForward.Enabled = true PlayerGui.CameraUI.ScreenGuiBackward.Enabled = true PlayerGui.CameraUI.ScreenGuiForward2.Enabled = false PlayerGui.CameraUI.ScreenGuiBackward2.Enabled = false end if script.Parent.CameraValue.Value == 2 then PlayerGui.CameraUI.ScreenGuiForward.Enabled = false PlayerGui.CameraUI.ScreenGuiBackward.Enabled = false PlayerGui.CameraUI.ScreenGuiForward2.Enabled = true PlayerGui.CameraUI.ScreenGuiBackward2.Enabled = true end script.Parent.ScreenGuiForward.ForwardBttn.MouseButton1Down:Connect(function() script.Parent.CameraValue.Value = 2 for i = 0,1,0.01 do workspace.CameraPart.CFrame:Lerp(workspace.CameraDestinations.CameraDes2.CFrame, i) wait() end end) script.Parent.ScreenGuiBackward2.BackwardBttn.MouseButton1Down:Connect(function() script.Parent.CameraValue.Value = 1 for i = 0,1,0.01 do workspace.CameraPart.CFrame:Lerp(workspace.CameraDestinations.CameraDes1.CFrame, i) wait() end end)
Could you please turn "script.Parent.CameraValue.Value" into a BoolValue? (and if you would like, rename CameraValue into FirstGuiEnabled) It would make this a lot easier