I am trying to work a remote event and I want a function from the local script to be activated from my main script. I got an error saying there was a missing argument in the main script, but I think I set it up wrong so I don't think this is the problem anyway. I am trying to make a gui appear on the player's screen but only when triggered by the serverscript.
here's the main script
local guiStart = game:GetService("ReplicatedStorage").TeamGuiStart guiStart:FireClient()
and the local script
local function teamFrameOn() local teamFrame = game.Players.LocalPlayer.PlayerGui.GUI.TeamFrame teamFrame.Visible = true end
Thank you!
Remote Event
do not have a member called FireAllClient
. Grammatically, that is an error and Roblox makes no exception on this either. It should be, if you still intend to fire for all Clients
, then you would use FireAllClients
with the s. It is a fairly small mistake, but in the end, it throws you an error.
FireAllClients
does not need an argument because the Remote Event
fires for all the connected users. Hence, no need for the Player
arguments.
To fire for a single player, you would have to specify a Player
argument.
-- [Declaration Section] --\\ Game Services local ReplicatedStorage = game:GetService("ReplicatedStorage"); local Players = game:GetService("Players"); --\\ Remote Event Location local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent"); -- [Processing Section] local function Fire_Players (Player) RemoteEvent:FireClient(Player); end; -- [Connecting Section] Players.PlayerAdded:Connect(Fire_Players);
-- [Declaration Section] --\\ Game Services local ReplicatedStorage = game:GetService("ReplicatedStorage"); --\\ Remote Event Location local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent"); -- [Processing Section] local function On_Client_Event () print("HI"); end; -- [Connecting Section] RemoteEvent.OnClientEvent:Connect(On_Client_Event);
Do keep in mind that, you do not always have to use Players
Service
to get the Players
. There are also other ways and that can be used as well.
Resources to learn
Replace the guiStart:FireClient() with guiStart:FireAllClient()
If you put guiStart:FireClient() it will only give you an error because you didn't specify the client. But, if you put guiStart:FireAllClient() you don't need to specify the client, because it will fire on all client's.