An issue I’ve had in my game I’ve been working on for a few months is that:
Whenever this specific GUI based QTE I have is played, based on how long you’ve been in the server it’ll become unreasonably laggy (frame skips), the longer you’re in the game, the worse they become.
I’ve tried looking through the microprofiler for a solution but the only bar even close to long is just Render and runJob.
Here’s the code for the GUI in question.
game.ReplicatedStorage.Remotes.Fight.DodgeMiniGame.OnClientInvoke = function(blockWindow, dodgeWindow, speed)
local s,e = pcall(function()
print("Minigame!")
block.Visible = true
block.Indicator.Position = UDim2.new(0.01,0,0,0)
block.Block.Size = UDim2.new(0.10 * blockWindow, 0, 1, 0)
block.Dodge.Size = UDim2.new(0.015 * dodgeWindow, 0, 1, 0)
local position = 0.5 + (math.random(0, 2)/10)
block.Block.Position = UDim2.new(position, 0, 0, 0)
block.Dodge.Position = UDim2.new(position, 0, 0, 0)
local blocked
local dodged
local tween = ts:Create(block.Indicator,TweenInfo.new(speed),{Position = UDim2.new(0.96,0,0,0)})
tween:Play()
local bind
local function Stop()
tween:Pause()
local blocking = collideservice.isColliding(block.Indicator,block.Block)
local dodging = collideservice.isColliding(block.Indicator,block.Dodge)
blocked = blocking
dodged = dodging
end
bind = game:GetService("UserInputService").InputBegan:connect(function(key, gameproccessed)
if key.KeyCode == Enum.KeyCode.Space then
Stop()
end
end)
block.Go.MouseButton1Click:Connect(function()
Stop()
end)
tween.Completed:Connect(function()
blocked = false
dodged = false
end)
repeat wait() until blocked ~= nil and dodged ~= nil
bind:Disconnect()
print(blocked)
print(dodged)
wait(0.5)
block.Visible = false
return {blocked,dodged}
end)
if s then
return e[1],e[2]
else
warn(e)
return "Error"
end
end
I should note this happens to all users, and is blatantly obvious that it’s caused by this.
Any help is appreciated.