No, i am not asking for to fix lag so i can play other games, I mean my game, roblox works fine on other games. a few minutes in my game that i created, all guis break, also the player count. I tried putting a local script in StarterPlayer in StarterPlayerScripts, the local script is below. After that, i put a CFrameValue and renamed it Renderable inside parts but that does not work, i don't know anymore solutions. I am hoping one of you guys can see the problem in the script, and there are no errors shown.
local HumanoidRootPart
local Workspace = game.Workspace
local Player = game.Players.LocalPlayer
local RenderParts = {}
local MaxRenderRadius = 50
local MinRenderOutRadius = MaxRenderRadius * 1
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Renderable") then
table.insert(RenderParts, v)
end
end
local function CharacterAdded(Character)
if Character then
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
end
end
CharacterAdded(Player.Character)
Player.CharacterAdded:Connect(CharacterAdded)
local function SetPartVisible(PartName, Visible)
if Visible == false then
PartName.Parent = nil
end
if Visible == true then
PartName.Parent = Workspace
end
end
while true do
wait(0.1)
if HumanoidRootPart then
for i=1, #RenderParts do
if RenderParts[i].ClassName ~= "Model" then
if (HumanoidRootPart.Position - RenderParts[i].Position).Magnitide >= MinRenderOutRadius then
SetPartVisible(RenderParts[i], false)
end
end
if RenderParts[i].ClassName == "Model" then
if (HumanoidRootPart.Position - RenderParts[i]:GetPrimaryPartCFrame().p).Magnitide >= MinRenderOutRadius then
SetPartVisible(RenderParts[i], false)
end
end
if RenderParts[i].ClassName ~= "Model" then
if (HumanoidRootPart.Position - RenderParts[i].Position).Magnitide <= MaxRenderRadius then
SetPartVisible(RenderParts[i], true)
end
end
if RenderParts[i].ClassName == "Model" then
if (HumanoidRootPart.Position - RenderParts[i]:GetPrimaryPartCFrame().p).Magnitide >= MaxRenderRadius then
SetPartVisible(RenderParts[i], true)
end
end
end
end
end

4 comments
I don't get what you mean, can you send a screen capture?
when i play my game, all the guis break, so as the basic leaderstats
You have an infinite loop checking for HumanoidRootPart, this is probably what's causing lag.
no, this script is trying to fix the lag