I have a localscript, script, and a remote event the localscript fires the remote event when i press a textbutton (code below)
local text = game.ReplicatedStorage:WaitForChild("Text") textlabel = script.Parent.Parent:WaitForChild("TextLabel") textlabel.Text = text.Value --This is a string value. text.Changed:Connect(function() textlabel.text = text.Value end) script.Parent.MouseButton1Down:Connect(function() game.ReplicatedStorage.TextChanger:FireServer() end)
Just to be clear, the localscript is parented under the textbutton and "TextChanger" is a remote event under replicatedstorage text is also parented under replicatedstorage
Below is the code for the normal script
local function textchange1(player) game.ReplicatedStorage:WaitForChild("text").Value = "Hello" end game.ReplicatedStorage.TextChanger.OnServerEvent:Connect(textchange1)
Now i've been searching for ways, but i can't find how to change the value/text more than once using one remote event. Do i have to use multiple Remote Events in order to change the text multiple times?
Local script:
local text = game.ReplicatedStorage:WaitForChild("Text") textlabel = script.Parent.Parent:WaitForChild("TextLabel") local newtext = "hi" textlabel.Text = text.Value --This is a string value. text.Changed:Connect(function() textlabel.text = text.Value end) script.Parent.MouseButton1Down:Connect(function() game.ReplicatedStorage.TextChanger:FireServer(newtext) -- sends 'newtext' to the server receiver end)
Server script:
local function textchange1(player, newtext) game.ReplicatedStorage:WaitForChild("text").Value = newtext -- set the value to 'newtext' end game.ReplicatedStorage.TextChanger.OnServerEvent:Connect(textchange1)