local function animateToiletPaper(toiletPaperId)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
local toiletPapers = game.Workspace.ToiletPaper:GetChildren()
local goldToiletPaper = game.Workspace.GoldToiletPaper:GetChildren()
local toiletPaper = nil
for _, v in toiletPapers do
if v.Name == toiletPaperId then toiletPaper = v end
end
for _, v in goldToiletPaper do
if v.Name == toiletPaperId then toiletPaper = v end
end
if toiletPaper == nil then return end
local up = TweenService:Create(toiletPaper, tweenInfo, {CFrame = CFrame.new(toiletPaper.Position.X, toiletPaper.Position.Y + 1, toiletPaper.Position.Z)})
local down = TweenService:Create(toiletPaper, tweenInfo, {CFrame = CFrame.new(toiletPaper.Position.X, toiletPaper.Position.Y - 1, toiletPaper.Position.Z)})
up:Play()
up.Completed:Connect(function()
if toiletPaper == nil then
up:Destroy()
down:Destroy()
return end
down:Play()
end)
down.Completed:Connect(function()
if toiletPaper == nil then
up:Destroy()
down:Destroy()
return end
up:Play()
end)
end
This tween is slowly lagging my game over time. It starts out fine, but after 20 minutes or so it becomes extremely laggy
