So, When you click on a button it changes the position of the camera. Simple, but I am having insane failure.
I’ve tried to debug this for over an 2 hours so I’m desperate for answers. The script is a local script.
local Gui = script.Parent.Parent
local Number = Gui.Number
local CommonFrame = Gui.ScrollingFrame
local RareFrame = Gui.RareRequirements
local EpicFrame = Gui.EpicRequirements
local CurrentCam = workspace.CurrentCamera
local commoncam = workspace.ChiikenShop.CommonChiiken.camera
local rarecam = workspace.ChiikenShop.RareChiiken.camera
local epiccam = workspace.ChiikenShop.EpicChiiken.camera
local clicks = 1
script.Parent.MouseButton1Click:Connect(function()
clicks += 1
print("clicked")
if Number.Value == 1 then
print("1 fired")
RareFrame.Visible = true
CurrentCam.CameraType = Enum.CameraType.Custom
CurrentCam.CameraType = Enum.CameraType.Scriptable
CurrentCam.CFrame = rarecam.CFrame
wait(1)
repeat
wait(0.1)
until
clicks == 2
print("click1")
Number.Value = 2
RareFrame.Visible = false
end
if Number.Value == 2 then
print("2 fired")
EpicFrame.Visible = true
CurrentCam.CameraType = Enum.CameraType.Custom
CurrentCam.CameraType = Enum.CameraType.Scriptable
CurrentCam.CFrame = epiccam.CFrame
wait(1)
repeat
wait(0.1)
until
clicks == 3
print("Click2")
Number.Value = 3
EpicFrame.Visible = false
end
if Number.Value == 3 then
print("3 fired")
CommonFrame.Visible = true
CurrentCam.CameraType = Enum.CameraType.Custom
CurrentCam.CameraType = Enum.CameraType.Scriptable
CurrentCam.CFrame = commoncam.CFrame
wait(1)
repeat
wait(0.1)
until
clicks == 4
print("CLICK3")
Number.Value = 1
CommonFrame.Visible = false
clicks = 0
end
end)
There are no errors or warnings, just the things I printed in that script.
However, only the first if statement fires. I am unsure why or how.
then you are adding a click when you click the thing. That would not make sense because for the first one, you are running a statement when the clicks = 1, that would not be true because Clicks = 2. That would break the whole script. You need to fix that
Surprisingly, it did not work. I simply just changed the starting click value to 0 instead of 1 so the first if statement would fire but it did not fire.
runs the first if statement which proceeds to wait for clicks == 2
second click:
sets clicks to 2
runs the first if statement again because Number.Value is still 1
the wait for clicks == 2 from the first click now fires and sets Number.Value to 2
the wait for clicks == 2 from this click passes because clicks is 2 (doesnt do anything since number is already 2)
third click:
sets clicks to 3
runs the second if statement, which proceeds to wait for clicks == 3. clicks is already 3 so it just needs to wait the 1 second before it can pass the repeat loop to set Number.Value to 3
if you now click a 4th time before that until clicks == 3 passes, you now set clicks to 4, and that old repeat loop waiting for clicks == 3 will never pass. you will be forever stuck to Number.Value being 2
overall, your code is kinda jank you might need to reformat it lol