#Fps drop on any input

46 messages · Page 1 of 1 (latest)

wispy shuttleBOT
#

studio** You are now Level 7! **studio

tough shoal
thorn cradle
#

cant really show code since i do not know the source of the issue, i need help finding the source, i need to know what could be causing this in the first place

tough shoal
#

then how am i ment to help you fix code which you dont know of the issue with

cedar gate
#

you're probably connecting to uis every frame, beginners tend to make that mistake a lot

#

so whenever you press a button it fires a million times and just gets worse over time

thorn cradle
thorn cradle
#

but i think i got it now

#

I tested it by deleting all of the GUI's and its still happening, I will record the issue and it might help a bit

thorn cradle
#

and nothing else in the game is laggy

#

just when i press any input

cedar gate
#

where code

thorn cradle
#

hold on im gonna try the gui part again

#

i might have figured it out

#

its already present even before i press any button but it might be this hold on

tough shoal
#

use performance stats

#

or whatever its caelled

thorn cradle
#
local PlayButton = script.Parent
local playGui = PlayButton.Parent
local teamSelectGui = player:WaitForChild("PlayerGui"):WaitForChild("TeamSelectGui")

local camera = workspace.CurrentCamera
local cameraPart = workspace:WaitForChild("Cameras"):WaitForChild("cameraPart")
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local playerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local controls = playerModule:GetControls()
controls:Disable()

humanoidRootPart.Anchored = true

local function setCameraToPart(part)
    camera.CameraType = Enum.CameraType.Scriptable 
    camera.CFrame = part.CFrame 
end


local function resetCameraToPlayer()
    camera.CameraType = Enum.CameraType.Custom 
    camera.CameraSubject = player.Character:WaitForChild("Humanoid") 
end


local function disableAllGUIs()
    for _, gui in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
        if gui:IsA("ScreenGui") and gui ~= playGui then
            gui.Enabled = false
        end
    end
end

-- Enable all GUIs
local function enableAllGUIs()
    for _, gui in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
        if gui:IsA("ScreenGui") then
            gui.Enabled = true
        end
    end
end


setCameraToPart(cameraPart)
disableAllGUIs()


PlayButton.MouseButton1Click:Connect(function()
    
    controls:Enable()
    humanoidRootPart.Anchored = false

    
    playGui.Enabled = false

    
    teamSelectGui.Frame.Visible = true

    
    resetCameraToPlayer()

    
    for _, gui in pairs(player:WaitForChild("PlayerGui"):GetChildren()) do
        if gui:IsA("ScreenGui") and gui ~= playGui then
            gui.Enabled = true
        end
    end
end)


for _, button in pairs(teamSelectGui:GetDescendants()) do
    if button:IsA("TextButton") or button:IsA("ImageButton") then
        button.MouseButton1Click:Connect(function()
            if not teamSelectGui.Frame.Visible then
                button.Active = false
            else
                button.Active = true
            end
        end)
    end
end
tough shoal
#

you can also use script performance

thorn cradle
#

code of a play button

tough shoal
#

which will show you what scripts are doing

thorn cradle
#

i didnt make the code since im the vfx designer so i dont know what my guy messed up here

thorn cradle
tough shoal
#

micro profiler as well

#

i think its called

thorn cradle
#

every time i press a button the micro profiler goes up

#

like this

tough shoal
#

what events are you lisening for

#

like userinput ect?

thorn cradle
tough shoal
#

??

#

look at one of thoes frames

#

and which service it is using

thorn cradle
#

alright 1 sec

#

do i like switch it here?

#

i never used micro profiler before

#

oh i think i got it

#

i dont have any groups selected, not even ALL and it still looks like this

#

okay i realized its one of these scripts, since when i disabled them the issue was solved

#

i will return later