pyxfluff
(Pyx)
December 11, 2021, 5:01pm
#1
Hi!
I’m having an issue with my camera script. It works fine, but it causes lag and piles up.
Thanks for any help!
Scroll part of my cam script:
Mouse.WheelBackward:Connect(function()
getCamPart().Position = getCamPart().Position + Vector3.new(0, .001, 0)
game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
--orientation = CFrame.Angles(math.rad(0), RotR + RotL, math.rad(0)) * Camera.CFrame
CFrame = getCamPart().CFrame
}):Play()
end)
Mouse.WheelForward:Connect(function()
getCamPart().Position = getCamPart().Position - Vector3.new(0, .001, 0)
game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
--orientation = CFrame.Angles(math.rad(0), RotR + RotL, math.rad(0)) * Camera.CFrame
CFrame = getCamPart().CFrame
}):Play()
end)
Video: (still processing rn, give it a minute)
Thanks!
Tyler148
(Teccs)
December 11, 2021, 5:04pm
#2
How frequently is WheelBackward or WheelForward being called? You may have to limit the amount of times it may be called in a time frame. Scrollwheel input can exponentially grow depending on the hardware some players have (like an unlocked mouse wheel)
pyxfluff
(Pyx)
December 11, 2021, 5:06pm
#3
I have it running like this
game:GetService("RunService").RenderStepped:Connect(function(step)
if not IsBuilding then return end
if not getCamPart() then --WILL finish later
--more of my trash camera code
while task.wait(0.05) do
--more hot garbage
if IsBuilding then
Mouse.WheelBackward:Connect(function()
getCamPart().Position = getCamPart().Position + Vector3.new(0, .001, 0)
game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
--orientation = CFrame.Angles(math.rad(0), RotR + RotL, math.rad(0)) * Camera.CFrame
CFrame = getCamPart().CFrame
}):Play()
end)
Mouse.WheelForward:Connect(function()
getCamPart().Position = getCamPart().Position - Vector3.new(0, .001, 0)
game:GetService("TweenService"):Create(Camera, TweenInfo.new(0.05, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0), {
--orientation = CFrame.Angles(math.rad(0), RotR + RotL, math.rad(0)) * Camera.CFrame
CFrame = getCamPart().CFrame
}):Play()
end)
task.wait(0.05)
end
end
end)
ignore the ends and if statements, i kinda deleted random parts for that code
pyxfluff
(Pyx)
December 11, 2021, 10:10pm
#4
Kinda forgot this existed until I tested again, it’s still an issue.
pyxfluff
(Pyx)
December 12, 2021, 4:27pm
#5
Turns out it’s some sort of Memory leak…
Tyler148
(Teccs)
December 12, 2021, 5:09pm
#6
If it’s a memory leak issue, could the connections be getting duplicated or connected more than once?
pyxfluff
(Pyx)
December 12, 2021, 8:28pm
#7
I dont think, the loop info is in an above post.