So I am making an admin script and I am trying to make an fps (frames per second) command so a player can view their current frame rate, the code was working up until now and it still updates every few milliseconds and changes colour based off the frame rate performance but when I type out the command again to turn it off, it says FPS is not a valid member of ScreenGui “FPSGui”
elseif msg:lower():sub(1,4) == freeCommandPrefix.."fps" then --FPS command (Frames Per Second)
if plr.PlayerGui:FindFirstChild("FPSGui") == nil then
local clonedUi = script.FPSGui:Clone()
clonedUi.Parent = plr.PlayerGui
while wait(0.1) do
local fps = math.floor(game.Workspace:GetRealPhysicsFPS())
clonedUi.FPS.Text = "FPS: "..fps
if fps <= 35 then
clonedUi.FPS.TextColor3 = Color3.fromRGB(255, 38, 19)
elseif fps > 35 and fps <= 40 then
clonedUi.FPS.TextColor3 = Color3.fromRGB(255, 255, 39)
elseif fps > 40 and fps <= 60 then
clonedUi.FPS.TextColor3 = Color3.fromRGB(57, 255, 47)
elseif fps > 60 then
clonedUi.FPS.TextColor3 = Color3.fromRGB(19, 255, 240)
end
end
else
plr.PlayerGui:FindFirstChild("FPSGui"):Destroy()
end
I have tried using find first child for finding the FPS text label but it still says attempt to index nil with ‘Text’
Hello again, I found out the error was that because my fps command is for an entire admin system, I have it set so the owner of the game is automatically given admin and I published the game only recently but I still had my user Id in the array of admins, I forgot to remove it so it was replicating the command and doing it twice.