Hello there, I made a LocalScript, a script and a RemoteEvent for my current situation that I have which is that a TextLabel changes it's text for all players to see when a player presses a button, but it does not seem to work, How do I fix this?
SERVERSCRIPT:
local RS = game:GetService("ReplicatedStorage")
local AnnounceEvent = RS:WaitForChild("AnnounceEvent")
AnnounceEvent.OnServerEvent:Connect(function(player)
AnnounceEvent:FireClient()
end)
LOCALSCRIPT:
local player = game:GetService("Players").LocalPlayer
local PlayerName = player.DisplayName
local RS = game:GetService("ReplicatedStorage")
local AnnounceEvent = RS:WaitForChild("AnnounceEvent")
local text = player.PlayerGui.Announce.TextLabel
local text2 = player.PlayerGui.Roll.TextLabel
local button = player.PlayerGui.Roll.TextButton
local value = player.PlayerGui.Roll.Value
button.MouseButton1Click:Connect(function()
text.Text = PlayerName..' has rolled '..text2.Text
AnnounceEvent:FireServer(text.Text)
end)

2 comments
Doesn't this changes the text for the StarterGui instead of the PlayerGui, plus I can't fetch the PlayerGui in the Server Script so I have to use RemoteEvents to fetch it
No not really, you got to use the: WaitForChild() statement for things that get created later on in time.