Hello! I have this issue with my script where the IntValue won’t subtract or add up properly. It skips a few numbers. It goes from 1 to 2 to 4 to 6 and vice versa. Here is the script:
local Camera = game.Workspace.CurrentCamera
local ShelfFrame = script.Parent.ShelfFrame
local GameName = ShelfFrame.GameName
local GameDescription = ShelfFrame.GameDescription
local Cartridges = workspace.Room.Cartridges:GetChildren()
local TweenService = game:GetService("TweenService")
local ContextActionService = game:GetService("ContextActionService")
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.Room.Cartridges["Tom&Dan"].CameraPart.CFrame
local CurrentCartridge = workspace.Room.Cartridges["Tom&Dan"]
local CurrentOrderValue = 1
local Cooldown = 0.1
local CanScroll = true
local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = StartPart.CFrame
local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame}):Play()
end
local function ScrollRight(inputName, inputState, input)
if inputState == Enum.UserInputState.Begin and CanScroll == true then
CanScroll = false
for _, cartridge in pairs(workspace.Room.Cartridges:GetChildren()) do
if cartridge and cartridge.OrderValue.Value == CurrentOrderValue + 1 then
MoveCamera(Camera, cartridge.CameraPart, 0.1, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
CurrentCartridge = cartridge
CurrentOrderValue = cartridge.OrderValue.Value
GameName.Text = cartridge.GameName.Value
GameDescription.Text = cartridge.GameDescription.Value
end
end
wait(Cooldown)
CanScroll = true
end
end
local function ScrollLeft(inputName, inputState, input)
if inputState == Enum.UserInputState.Begin and CanScroll == true then
CanScroll = false
for _, cartridge in pairs(workspace.Room.Cartridges:GetChildren()) do
if cartridge and cartridge.OrderValue.Value == CurrentOrderValue - 1 then
MoveCamera(Camera, cartridge.CameraPart, 0.1, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
CurrentCartridge = cartridge
CurrentOrderValue = cartridge.OrderValue.Value
GameName.Text = cartridge.GameName.Value
GameDescription.Text = cartridge.GameDescription.Value
end
end
wait(Cooldown)
CanScroll = true
end
end
ContextActionService:BindAction("Right", ScrollRight, true, Enum.KeyCode.D, Enum.KeyCode.DPadRight)
ContextActionService:SetTitle("Right", "Next")
ContextActionService:SetPosition("Right", UDim2.new(0, 0, 0, 0))
ContextActionService:BindAction("Left", ScrollLeft, true, Enum.KeyCode.A, Enum.KeyCode.DPadLeft)
ContextActionService:SetTitle("Left", "Previous")
ContextActionService:SetPosition("Left", UDim2.new(0, 0, 0, 0))
Here is an image of the Room folder
Here is a video of how it looks like:
I really don’t know what to do, I’ve been trying to fix this for a few hours now and nothing.