I have this roblox script to where when the player clicks the textbutton and it should change the text of the textlabel to the text what the text of the TextBox text is.
It should do that but it’s not.
I have redone it about 10 times.
No clue.
-- --
local textButton = script.PArent.Parent.Parent.Frame1.TextButton
local textBox = script.Parent.Parent.Parent.Frame1.TextBox
local textLabel = script.Parent
local function onTextButtonClicked()
textBox.Text = textLabel.Text
end
textButton.MouseButton1Click:Connect(onTextButtonClicked)
That’s where I am so far. No idea what’s wrong or how I make it acheive what I want.

2 Likes
use a localscript instead of a script
1 Like
use a local script instead of a script
1 Like
Thank’s! I found the rest of the bugs after I changed it to local. I don’t know how I forgot to make it a local script. Do you know how I can make it to where everyone sees the change of text.
1 Like
Use a remoteevent and fire it to all clients from the server when you want to change the text
1 Like
I have this script that goes in ServerScriptStorage. That fires the remote event.
local textButton = game.StarterGui.ScreenGui.Frame1.TextButton
local textBox = game.StarterGui.ScreenGui.Frame1.TextBox
local textLabel = game.StarterGui.ScreenGui.Frame.TextLabel
local function onTextButtonClicked()
textLabel.Text = textBox.Text
end
textButton.MouseButton1Click:Connect(onTextButtonClicked)
local changeTextEvent = Instance.new(“RemoteEvent”)
changeTextEvent.Name = “ChangeTextEvent”
changeTextEvent.Parent = game:GetService(“ReplicatedStorage”) – You can also create a separate folder for Remotes
local changeTextEvent = game:GetService(“ReplicatedStorage”):WaitForChild(“ChangeTextEvent”)
local textBox = script.Parent.TextBox – Reference to the TextBox
– Function to change the text on the client
local function changeTextOnClient(newText)
textBox.Text = newText
end
changeTextEvent.OnClientEvent:Connect(changeTextOnClient)
1 Like
Let me type in the other code. Just 1 minute.
1 Like
Here is the second code that goes in StarterPlayerScripts.
local changeTextEvent = game:GetService(“ReplicatedStorage”):WaitForChild(“ChangeTextEvent”)
local textBox = game.StarterGui.ScreenGui.Frame1.TextBox
local function changeTextOnClient(newText)
textBox.Text = newText
end
– Connect the function to the event
changeTextEvent.OnClientEvent:Connect(changeTextOnClient)
1 Like
It’s still not working. Any ideas why may script is not working.
Can you correctly codeblock your script?
--please?
-- Create a RemoteEvent
local changeTextEvent = Instance.new("RemoteEvent")
changeTextEvent.Name = "ChangeTextEvent"
changeTextEvent.Parent = game:GetService("ReplicatedStorage") -- You can also create a separate folder for Remotes
-- Function to change the text and replicate the change to clients
local function changeTextOnServer(player, newText)
-- Perform any validation or security checks here before changing the text
-- Get reference to the TextBox
local textBox = player.PlayerGui:WaitForChild("ScreenGui"):FindFirstChild("Frame1"):FindFirstChild("TextBox")
if textBox then
textBox.Text = newText
end
-- Fire the event to all clients
changeTextEvent:FireAllClients(newText)
end
-- Connect the function to the event
changeTextEvent.OnServerEvent:Connect(changeTextOnServer)
Script 2
local changeTextEvent = game:GetService("ReplicatedStorage"):WaitForChild("ChangeTextEvent")
local textBox = game.StarterGui.ScreenGui.Frame1.TextBox
local function changeTextOnClient(newText)
textBox.Text = newText
end
-- Connect the function to the event
changeTextEvent.OnClientEvent:Connect(changeTextOnClient)
Also, change MouseButton1Click to Activated, because .Activated has mobile support while .MouseButton1Click does not.
.MouseButton1Click
works on mobile, what are you talking about?