I am creating a mining game currently. I have created a mining tool in which the following code samples exist:
Local script:
connection = tool.Activated:Connect(function()
if active ~= true then
active = true
re:FireServer(target)
target = nil
end
connection:Disconnect()
end)
tool.Deactivated:Connect(function()
if active == true and waiting == false then
waiting = true
connection:Disconnect()
task.wait()
active = false
waiting = false
end
end)
(Where target is defined by the mouse target block, active and waiting are defined as “false” earlier in the script, and re is a remote event)
Global script:
local sp = script.Parent
local re = script.remoteevent
local function activate(plr, target)
if target then
target:Destroy()
end
target = nil
plr = nil
end
re.OnServerEvent:Connect(activate)
The problem I am facing is that the more blocks I mine, the more terrible my fps seems to get. I do run a low end pc but this never happens in other mining games I’ve played. I go from a solid 60 fps to less than 15 if I mine for long enough. I’ve tried fixing this by adding connections & disconnecting them, adding wait times, defining target & plr as nil at the end of the global script, making sure the target actually still exists when it gets to the global script and probably a couple other things I forgot about. Not sure what to do!