Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

text label change for every player?

Asked by 5 years ago

look at the link to see what I am talking about (: https://gyazo.com/0e2b030f1e9a17eabcf93bdfc4aba53d

How would I make what I type in the screen gui text box change the text label on the part for everyone? not just myself?

my code in the screen gui text box:

local screenTextbox = script.Parent local partTextLabel = game.Workspace.PartGui.SurfaceGui.TextLabel

screenTextbox.FocusLost:Connect(function(enterPressed) if enterPressed then partTextLabel.Text = screenTextbox.Text end end)

(yes that is in a local script and works just not for everyone only on my end if that makes sense)

0
use remote events greatneil80 2647 — 5y
0
Watch this video on remote events https://www.youtube.com/watch?v=wic-N4JiFss&t=771s. Gameplay28 139 — 5y
0
I've already given you an example of this, have you not looked at my previous answer? Ziffixture 6913 — 5y
0
Hm, judging by the changes you have, and decided to pretend you didn't. That's just mean Ziffixture 6913 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

As said in the comments, you need to use a Remote Event. I'll give you a quick explanation on what those are.

Well, first we need to start off with local scripts. Local scripts only run on the client, or your side of the game. So any code you try to run in a local script will only effect your screen. This is why the script seems to work, but only for you.

However, that's where Remote Events come in. Basically what they do is run code in a server script when activated from a local script. They can also communicate the reversed way, server running code in a local script, but this isn't important at the moment.

I will provide a basic example of using a Remote Event:

Insert a RemoteEvent into ReplicatedStorage, leaving it at its default name, RemoteEvent.

-- Local Script
local Plr = game.Players.LocalPlayer
local Mou = Plr:GetMouse()
local RS = game:GetService("ReplicatedStorage") -- Getting ReplicatedStorage, where the RemoteEvent object is stored.


Mou.Button1Down:Connect(function() -- Activates (whatever code inside)  whenever the mouse is pressed down.
    RS.RemoteEvent:FireServer() -- RemoteEvent:FireServer()... Fires or signals the server...
end)
-- Server Script
local RS = game:GetService("ReplicatedStorage") -- Referencing ReplicatedStorage again because it's a separate script.

RS.RemoteEvent.OnServerEvent:Connect(function() -- Whenever the RemoteEvent is fired or signaled, as I said in the local script, it will run this function.
    local Part = Instance.new("Part") -- Creating a new part...
    Part.Parent = workspace -- and setting the parent to workspace so, well, you can see where it is.
end)

Finished, now you successfully made it so whenever the player clicks, a part is created in workspace that replicates to the server. Now all you have to do is incorporate this concept into your script if you are trying to make server changes via local script.

Ad

Answer this question