This is what i meant:
Say you have a localscript parented under a text button which fires a remote event under a folder under ReplicatedStorage
Localscript code:
textfolder = game.ReplicatedStorage:WaitForChild("TextFolder") text = game.ReplicatedStorage:WaitForChild("TextValue") -- This is a string value textlabel = script .Parent.Parent:WaitForChild("TextLabel") -- the TextButton is parented under a frame and the textlabel is also parented under the frame text1 = "Hello" text2 = "My name is Bob" textchange1 = false textchange2 = false textlabel.Text = text.Value text.Changed:Connect(function() textlabel.text = text.Value end) script.Parent.MouseButton1Down;Connect(function() textfolder.TextChanger1:FireServer(text1) --TextChanger is a Remote Event textchange1 = true end) script.Parent.MouseButton1Down;Connect(function() if textchange1 == true then textfolder.TextChanger2.FireServer(text2) textchange2 = true end end)
and then you have a script inside serverscriptservice
script code:
textfolder = game.ReplicatedStorage:WaitForChild("TextFolder") text = game.ReplicatedStorage:WaitForChild("TextValue") local function textchange1(player,text1) game.ReplicatedStorage:WaitForChild("TextValue").Value = text1 end local function textchange2(player,text2) game.ReplicatedStorage:WaitForChild("TextValue").Value = text2 end textfolder.TextChanger1.OnServerEvent:Connect(textchange1) textfolder.TextChanger2.OnServerEvent:Connect(textchange2)
Now when i click the textbutton the first time, textvalue's value changed, but when i click it the 2nd time, it doesn't.
Is it possible the 2nd remote event (which is supposed to change the value for the 2nd time) TextChanger2, gets fired at the same time TextChanger1 gets fired? (when i press the textbutton)
You're using two MouseButton1Down listeners; both are called with every click. You need to conditionally handle it in a single listener.
script.Parent.MouseButton1Down;Connect(function() if not textchange1 == true then textfolder.TextChanger1:FireServer(text1) --TextChanger is a Remote Event textchange1 = true else textfolder.TextChanger2.FireServer(text2) textchange2 = true end end)
Edit:
To expand on that; the reason why both were firing is because the first MouseButton1Down listener fired TextChanger1 regardless of textchange1 or textchange2. Because the second listener did conditionally fire it's event; it wouldn't have happened the first click.