I’m currently trying to make a AGT like Buzzer System and am working on the colors. Currently everything works good until after pressing the Reset button. When pressing it, the X’s will change back to black. But when trying to press a button again will result in nothing changing… What’s going on?
Video:
Button Code:
local Button = script.Parent.Parent.Parent.B3
local Main = game.Workspace.Main
local Buttons = game.Workspace.Buttons
local ClickDetector = script.Parent.ClickDetector
local Sound = game.Workspace.Sound
ClickDetector.MouseClick:Connect(function()
local Tween1 = game.TweenService:Create(Main.X3.Color, TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {["Color"] = Color3.fromRGB(255, 0, 0)})
Tween1:Play()
Sound:Play()
end)
Reset Button Code:
local Main = game.Workspace.Main
script.Parent.MouseButton1Click:Connect(function()
for i,v in pairs(Main:GetChildren()) do
local Tween1 = game.TweenService:Create(v.Color, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {["Color"] = Color3.fromRGB(0, 0, 0)})
Tween1:Play()
end
end)
The problem is most likely that you change the color to red on the server, but black on the client. Fire a remote event to change the color back instead of doing it in a local script. For an explanation, the server already sees it as that color, and therefore makes no changes.
No, the server changes it to red. You can tell because the click detector is within the workspace along with a script, meaning, for it to work, it would have to be a server script. As for the GUI button, common sense would conclude that it is a local script. The server changes it to red, and the client changes it back to black. So, when he presses the button again after a reset, the server already views it as red and makes no changes when tweening the object color. If the server sees the color as what it is trying to be changed, the server will not take action so it won’t waste performance on changing the color to what it already is.
That’s my whole point, The Color he seeing is not the Server Side seeing. So he have 2 problems, but I am recommending him to also put the function in Local Method so he can run the Function again along the Mouse Click
That’s the thing. The client doesn’t see the color that the server sees because the client changed it to black. The client only updates the color when the server changes the color. Since the server does not take action when the color is the same, it leads to the update not running and the client sticking to seeing black.
You do realize this would cause more problems, right? Judging by what he is trying to make, I would assume he wants the whole server to see it and not just the person that clicks the button. By changing it to all local, only the client would see it.
Also, Do you know how to Connect a function? that would be the answer to your question, you should connect a local function for it to work. Or do you want a example?
I’m not sure where you’re getting this from. The topic was quite literally solved by my first comment, so I don’t see the point in continuing this conversation. Yes, I know how to connect a function, but that has nothing to do with this at all. Connecting a local function doesn’t suddenly make the event local as local function is typically used when you want to make a function inside of another function if you won’t use it outside of that function. ex:
function sayhi()
local function printmsg(msg)
print(msg)
end
printmsg("hi")
end
sayhi()
printmsg("test") -- will error since function was defined as a "local" function inside of the function
function sayhi()
function printmsg(msg)
print(msg)
end
printmsg("hi")
end
sayhi()
printmsg("test") -- will work since function was made and was not defined as a "local" function
Yes, you use functions to connect events, but a local function won’t be any different from a normal function in this case. A local function doesn’t suddenly make the server act on the client, but rather just defines a function within a certain area of code without it affecting the other parts of the code.