Low GFX Mode GUI button does nothing on click

Hello!

I want to make it so all Materials that are known to be resource intensive (Glass, metal, etc…) to be set to Plastic once a GUI TextButton is clicked. I have code here that I know is working because it’s worked before.

local FlaggedMaterials = {Enum.Material.Glass, Enum.Material.Metal, Enum.Material.Ice, Enum.Material.DiamondPlate, Enum.Material.SmoothPlastic}
local PartsToChange = workspace:GetDescendants()

script.Parent.MouseButton1Click:Connect(function()
	for i, Part in pairs(PartsToChange) do
		--wait()
		if Part:IsA("BasePart") or Part:IsA("Part") then
			if table.find(FlaggedMaterials, Part.Material) then
				Part.Material = Enum.Material.Plastic
				print("Material Changed")
			end
		end
	end
	script.Parent.BackgroundColor3 = Color3.fromRGB(0,255,0)
	script.Parent.Text = "Rejoin to disable."
end)

For some reason, the button no longer does the code above. It gets Instances in the workspace then filters to see if it’s a part. Once it knows it’s a part, it will compare the parts material to one in the table and correct it to Plastic once found that it is one of the resource intensive textures.

What is happening? Did I make an error that is so simple yet I’m missing? Any help is appreciated.

Hopefully someone actually responds this time.

No errors? Can you verify the code is running? (Aka, putting prints here and there)

1 Like

The code isn’t disabled, so yes ofc it’s running.

image

The code doesn’t error, nor does it print anything. This is where I think the if statements are at fault, but they’re not because it’s worked in the past. Literally the code is the exact same, all I did was simply move GUI buttons. The old one doesn’t even work either.

Edit It also cannot be a loading issue because the user can only access the GUI once the game is entirely loaded.

I ran the code and it worked fine. The only change I made was switching the script type to server script, as I assume you’re running this from a local script due to registering button clicks.

Here’s my slight modification so I wouldn’t need to make a gui:

local FlaggedMaterials = {Enum.Material.Glass, Enum.Material.Metal, Enum.Material.Ice, Enum.Material.DiamondPlate, Enum.Material.SmoothPlastic}
local PartsToChange = workspace:GetDescendants()

local function run()
	for i, Part in pairs(PartsToChange) do
		--wait()
		if Part:IsA("BasePart") or Part:IsA("Part") then
			if table.find(FlaggedMaterials, Part.Material) then
				Part.Material = Enum.Material.Plastic
				print("Material Changed")
			end
		end
	end
	--script.Parent.BackgroundColor3 = Color3.fromRGB(0,255,0)
	--script.Parent.Text = "Rejoin to disable."
end

run()

Nothing substantial has changed which makes me think it might be because its running from a local script, which could be Filtering Enabled’s fault.

2 Likes

I just moved the PartsToChange variable inside the MouseButton1Click function and it now prints “Material Changed” despite not changing any parts.

Update:

That defeats the entire purpose of making it so lower end users can disable unneeded textures so things don’t need to look nicer. My goal is not to remove all the textures. If that was my goal, I simply would have done that from the beginning. I appreciate the help and suggestion though.

You misunderstood, I merely did that for testing purposes. AKA, to save time on my own end. I’ll make an actual gui this time and let’s see if your code still works.

I’m confused on how switching it to run makes a difference? If you connect it to a button click, run cannot be used anymore because that code only runs when the button is clicked. We’ll just be back at square one. I’m beginning to think this is an engine bug.

I think so as well, because I just tested it and it worked fine. Try restarting your client. Or perhaps you placed the local script in the wrong position?
image

Everything is fine here.

I actually closed studio after making this post and when you responded I opened it back up and it still didn’t work and that counts as a restart. Simply, that won’t work in this case.

Also, my GUI elements are all where they’re supposed to be. My script has everything referenced correctly, yet it yields in my game.

I moved the exact same GUI to another game, and now it performs perfectly fine. Perhaps that one place is glitched?

1 Like

Could be. I don’t know your situation, or whatever else is in that place. It might be something interfering with your scripts or your workplace? I doubt its a place glitch, but I guess you could just switch places if you really wanted to.

1 Like

I have 20k place visits. That’s a milestone in my eyes, and switching places would not be ideal.

My game is this one here

It has a lot of content, and that’s why I’m trying to make the experience for lower end users better and this low gfx mode thing helps prevent FPS fluctations which is a common problem within my place atm.

Can you show us a picture of your output?

1 Like

My output returns no errors. It says materials are changed, but nothing changes. Please read previous replies but thank you for asking that.

1 Like

It’s a pretty nice place. Obviously, I don’t have dark dex or whatever that thing is called so I can’t actually look into your place. You say the material changed was printed out, but it didn’t actually change?

I’m stumped. Your place is pretty huge, are you sure no parts have been changed at all?

2 Likes

I looked at the metal texture on the Gas Station poll and it stayed metal after pressing the button. I then did the same thing for another of my builds, here and it worked.

1 Like

I tested it and it worked fine, are u sure its not your studio or glitch?

1 Like

I did make slight changes, but they were not important

1 Like

The code worked before with no changes added onto it. A Work At a Pizza Place developer literally reviewed the code himself and told me about table.find() which is really useful.

I’m sure it’s worked before.

I’m running the latest studio because you have to be to actually develop games, and I don’t know if it’s a glitch. I didn’t even expect this to happen.

1 Like

Instead of restarting studio, try restarting your PC that’s all I got sorry man but its worth a try.

1 Like

Have you tried waiting for a bit after pressing the button? Perhaps its taking a while to go through all the parts you have, as it might be that your place has too many parts for the transformation to be instantaneous.

Other than that, I have no clue now. Sorry.

1 Like