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?
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.
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?