Hello I am trying to pass info to a local script I want to pass text to a local script then it show on a gui for all players

This is what I want to do

Server script:

local text
text = "Map has Loaded. Teleporting Players."
game.ReplicatedStorage.ChangeGui:FireAllClients(text) --//gui message

Local Script:

game.ReplicatedStorage.ChangeGui.OnClientEvent:Connect(function(plr, text)
	script.Parent.MainText.Text = text
end)

It must go through the server first

Local 1:

local text = "Map has Loaded. Teleporting Players."
game.ReplicatedStorage.ChangeGui:FireServer(text) --//gui message

Server:

game.ReplicatedStorage.ChangeGui.OnServerEvent:Connect(function(plr, text)
    game.ReplicatedStorage.ChangeGui:FireAllClients(text)
end)

Local 2

game.ReplicatedStorage.ChangeGui.OnClientEvent:Connect(function(text)
    script.Parent.MainText.Text = text
end)

sorry correction my first script is a server script sorry for the mistake

Well, OnClientEvent does not need the player as the first parameter, change this line

For this

alright I did i get the error that it thinks the “text” paramater is nil

I don’t know if this would change anything, but maybe declare your variable like so?

Local text = “Map is Loaded. Teleporting players.”

You don’t need a player parameter for OnClientEvent.

Be careful about what information is sent to the server. I understand this is an example but there is no filtering of the text and any player or even exploiter can fire this remote and display something bad to all the users.

it wouldnt change anything I dont think but ill try it

Found out the problem was with studio not comitting scripts

1 Like