I want to change a GUI’s Text through the server with a remote event. When the remote event is called, the LocalScript should detect this, but nothing happens. Also, is there any way I can set up a variable in the ServerScriptService script and use it in both scripts?
–Script in ServerScriptService
game.ReplicatedStorage.GUIEvent:FireAllClients()
–LocalScript in the GUI
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)
local function Intermission()
game.StarterGui.ScreenGui.TextBox.Text = “Intermission”–Want to connect variable from ServerScriptService script here
--Script in ServerScriptService
game.ReplicatedStorage.GUIEvent:FireAllClients('text')
--LocalScript in the GUI
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)
local function Intermission(text)
game.StarterGui.ScreenGui.TextBox.Text = text–Want to connect variable from ServerScriptService script here
end
remoteEvent.OnClientEvent:Connect(Intermission)
ok, so basically an argument is something you can send to the client so you’ll put the “Intermission” here:
--Script in ServerScriptService
game.ReplicatedStorage.GUIEvent:FireAllClients("Intermission") -- put whatever you want to send to the client here
--LocalScript in the GUI
local plr = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)
local function Intermission(text) -- the text augment is basically whatever you send from the server in this case it's a string "Intermission"
plr.PlayerGui.ScreenGui.TextBox.Text = text
end
remoteEvent.OnClientEvent:Connect(Intermission)
Check what errors occur when you have the local script like this:
-- local script
local plr = game.Players.LocalPlayer
local remoteEvent = ReplicatedStorage:WaitForChild(“GUIEvent”)
remoteEvent.OnClientEvent:Connect(function(text)
print('event fired')
script.Parent.Text = text
end)
It’s easier to figure out the problem when i can see the output