Part not changing color

i am very confused
i am trying to make all the parts to be back to color yellow, but it doesn’t work and if i change it to a different color such as red or blue all of them changes to that color

here is a simplified version of the script

module.clearMaps = function()
	for _, pad in pairs(votepads:GetChildren()) do
		pad.Color = Color3.fromRGB(245, 205, 48)
	end
end

its the same script, but different colors
i don’t know whats with that

the only think that i think could cause it would be changing the colors on the local side, but that shouldn’t cause the problem right?


Your not checking if the part is a BasePart.

it’s a parent to a folder, and it loops through all the parts, and there isn’t anything except those 3 parts

There isn’t enough information, follow this format while responding to me:

  • What is the problem? (The part not changing color.)
  • What should be happening. (What parts need to change color, or what should happen when it changes color.)
  • What isn’t happening?

Even tho you still should always check .

if part:IsA(“BasePart”) then
part.Color = Color3.FromRGB(R, G, B)
end

if you want i can send you the model, so you can see what’s going on

Where is the script that changes the part’s colour to green? If it’s a LocalScript, the buttons probably aren’t resetting because the server thinks the green button is already yellow when it loops through them.

To remedy this, you may be able to set up a remote event that tells every client to revert the buttons to yellow.

here is the place, you can check for yourself
testing place.rbxl (139.6 KB)

yeah the local script changes the part green

  1. the problem is that the all the parts are not changing to yellow and there is still a green part
  2. and what should be happening that there shouldn’t be a green part and all of the parts should be yellow
  3. and what isn’t happening is that the green part is still green and not yellow like the rest

Is the part a Union? If so, turn it to “UsePartColor”

This is what I was thinking was going on. Here’s a bit more of a detailed rundown of the problem:

  • All pads are yellow.
  • The client changes one pad’s colour to green on its side.
  • The server loops through all the parts to switch their colour to yellow, though on its end the green pad is still yellow since the client changed it locally. If it changes the pads’ colour to one that they never were originally (red), it will not skip the locally coloured pad since it would be updating its colour regardless of whether it’s considered green or yellow, and the override updates to the client.

To solve this, you can create a RemoteEvent in ReplicatedStorage that the module uses to tell the clients to reset the parts’ colour on their end.

	--[[ This commented code is removed
	for _, pad in pairs(votepads:GetChildren()) do
		pad.Color = Color3.fromRGB(245, 205, 48)
	end
	]]
	ReplicatedStorage.RemoteEvent:FireAllClients() --This is the RemoteEvent that changes the pads to yellow again
	for _, name in pairs(mapNames:GetChildren()) do
		name.SurfaceGui.MapText.Text = "None"
	end
	for _, vote in pairs(mapValues:GetChildren()) do
		vote.SurfaceGui.MapText.Text = 0
	end
	mapsVotes["Maps"] = {}
	mapsVotes["Votes"] = {}
	mapsVotes["Players"] = {}
end

Concept for the receiver (in a LocalScript, probably the one that colours them green in the first place):

ReplicatedStorage:WaitForChild("RemoteEvent").OnClientEvent:Connect(function()
	for _, pad in ipairs(workspace.VotePads:GetChildren()) do
		pad.Color = Color3.fromRGB(245, 205, 48)
	end
end)

i think i might of found an easier way to do this besides using remote events, you know how they all changed to red when i set the rgb value to (255,0,0), what if if i did the same but have set either one of the r, b, or green values by an offset of one

	for _, pad in pairs(votepads:GetChildren()) do
        pad.Color = Color3.fromRGB(245, 205, 47) -- new color
		pad.Color = Color3.fromRGB(245, 205, 48) -- original color
	end

i know this might be a hacky way to fix this problem, but i think it’ll work?

That looks like it could be a valid workaround as well. You can test it and see if it works.

1 Like

it works! thank you so much for helping me!