so I’m going to have a Award ceremony for my community.
I made a TextButton and a TextBox that only certain people have access to, to type in the screen.
The script works fine but the problem is, the text on the screen is seen by only who is typing in the TextBox.
there is no way to make a button click script by a normal server script, only by a LocalScript.
I want the button to show the text on the screen for all players, not just me, but I don’t know how to do it, that’s a problem, support is appreciated.
Here’s the simple script I’ve made.
local button = script.Parent
local text = workspace.Screen.ScreenItself.Awards.AwardsText -- SurfaceGui - TextLabel
button.MouseButton1Click:Connect(function()
local box = script.Parent.TextBox
text.Text = box.Text
end)
And I’ve also tried making variables without the “local” keyword, doesn’t change…
This can be achieved by using something called a RemoteEvent in order to allow the client to do things that perform actions on the sever. I have included a script below that would work in your case.
-- Make this a LocalScript and keep it where you have it right now.
local button = script.Parent
button.MouseButton1Click:Connect(function()
local box = script.Parent.TextBox
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
remoteEvent:FireServer(box.Text)
end)
Then, you will go to a server-sided script and detect when the RemoteEvent is fired, and perform an action. Another example below.
-- Make this a normal script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,msg) -- first argument is always player, therefore we need to add "msg" after it.
game.Workspace.Screen.ScreenItself.Awards.AwardsText = msg
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,msg) -- first argument is always player, therefore we need to add "msg" after it.
game.Workspace.Screen.ScreenItself.Awards.AwardsText = msg
end)
I’m trying this right now, thank you, I’m testing if it works, are there more ways to do this stuff? because it’s too complicated for me, I’ve never touched RemoteEvents and additional stuff like that…
Without a decent knowledge of scripting, I can understand why this is challenging and somewhat difficult to understand. RemoteEvents are extremely useful things and they are actually probably the easiest way to do stuff like this in most cases. At first, I appreciate that they may seem complicated, but there are many tutorials on YouTube and a detailed Developer Hub article on RemoteEvents and RemoteFunctions, which I recommend you take a look at to find out a bit more.