robloxapp-20240703-1559438.wmv (1.8 MB)
Hello. I wrote a script to scroll the wheel. StudsY is the camera’s distance from the character. I want to make sure there is some kind of limitation. I’ll attach a video to make it clear what I mean.
uis.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel then
if input.Position.Z > 0 then
StudsY -= 1
else
StudsY += 1
end
end
end)
Just check if CameraScroll Y position is not higher and not smaller than min and max value, otherwise just dont run your function/code and e.t.c, in your script you need to check camera StudsY inside your condition.
if StudsY >= 5 and StudsY <= 15 then
if input.UserInputType == Enum.UserInputType.MouseWheel then
if input.Position.Z > 0 then
StudsY -= 1
else
StudsY += 1
end
end
end
But because of this, if the StudsY variable reaches 15 or 5, the script stops working
if input.UserInputType == Enum.UserInputType.MouseWheel then
if input.Position.Z > 0 then
if StudsY >= 5 then
StudsY -= 1
end
else
if StudsY <= 15 then
StudsY += 1
end
end
end
if input.UserInputType == Enum.UserInputType.MouseWheel then
if input.Position.Z > 0 then
StudsY = math.max(StudsY-1,5) --This won't get below 5
else
StudsY = math.min(StudsY+1,15) --This won't go above than 15
end
end