How to script a text button gui that removes or changes transparency of objects in game?

Hello, I am making a car game called Road Taker, and I want it to look visually pleasing. The problem is, lag. I am using a pretty cheap laptop to build my game on. Whenever I test the game I always put my graphics settings on the lowest. I even managed to make a gui that disables shadows and does other things for Performance.
Even with all of these in place I still get random frame drops and lag. So I feel like if I can add a “Disable Trees & Grass” button to my gui, the game would run insanely smoother. I still want it to look nice for my friends with higher end pc’s which is mainly why I do not want to remove the trees & grass from the game. They could enjoy the visuals while I can play the game with them without that much lag.

If you want to talk directly feel free to dm on Discord:

1 Like

I think what you could do, is first put through all the Trees & Detail related stuff through a loop so that it goes through all the objects

I’ll show an example here:

--Since we're talking about a TextButton that will activate when clicked, we'll use the MouseButton1Click Event

local DetailFolder = workspace.DetailFolder --This is where to put all of the stuff you want to disable/enable
local Button = script.Parent --We're parenting backwards to define where the button is

local function DisableGraphics() --This is our function that activates when the button is clicked
    for _, Object in pairs(DetailFolder:GetChildren()) do --Loop through the objects
        Object.Transparency = 1 --Making them invisible to the client (Not sure if defining them as nil could bring them back)


Again, this is just a broad example on what you could do :thinking:

Really appreciate your example. This helped a lot. Thank you.

1 Like