I have a textLabel that I am gonna use to show people their FPS - Frames Per Second in the game, I want it so whatever the string of FPS is the string of textLabel is too, I don't know how to do this but wrote attempt codes here:
local textLabel = Instance.new("TextLabel") textLabel.Parent = screenGui textLabel.Position = UDim2.new(0, 1450, 0, 700) textLabel.Size = UDim2.new(0, 100, 0, 80) textLabel.BackgroundColor3 = BrickColor.Black().Color textLabel.Text = "0" textLabel.Font = "Legacy" textLabel.FontSize = 9 textLabel.TextColor3 = BrickColor.White().Color textLabel.BorderColor3 = BrickColor.White().Color NewInformation = "XYZ" if game.Workspace.FPS == "XYZ" then textLabel.Text = "XYZ" end
and
local textLabel = Instance.new("TextLabel") textLabel.Parent = screenGui textLabel.Position = UDim2.new(0, 1450, 0, 700) textLabel.Size = UDim2.new(0, 100, 0, 80) textLabel.BackgroundColor3 = BrickColor.Black().Color textLabel.Text = "0" textLabel.Font = "Legacy" textLabel.FontSize = 9 textLabel.TextColor3 = BrickColor.White().Color textLabel.BorderColor3 = BrickColor.White().Color if game.Workspace.FPS == "59.9" or "60" then textLabel.Text = "60" end
But the problem is I don't think that is how you locate the game's FPS and I don't think that is how you put the string on the textLabel, I honestly have no idea can you guys help me?
You are correct about setting the Text
property of a TextLabel object.
Now then, you can get a client's framerate through the GetRealPhysicsFPS
method of Workspace:
textLabel.Text = game.Workspace:GetRealPhysicsFPS()
Of course, since the framerate is different from player to player, you will have to do this from a clientside script.
Note that GetRealPhysicsFPS
's return value is a number, while a TextLabel's Text
property is of type string. This isn't a problem for us, as numbers in Lua are automatically converted to string when necessary.
Conclusion
So, there you have it. Easy, right?
If this helped then please be sure to accept, and optionally upvote, my answer. It helps both of us. ;) If you need anything else, you need only ask.
in a localscript
local fps = workspace:GetRealFPSPhysics() local text = tostring(fps) print(text)