I am trying to fire a RemoteEvent, and this is my first time ever using RemoteEvents. I am currently looking on different sites for answers, like developer.roblox.com, where they have a section for RemoteEvents, so I took code samples from there, and edited them.
Server Sided Code
local player = game.Players.LocalPlayer local Owners = {"SkyFume"} local Superadmins = {} local Admins = {} local Mods = {} local CustomRanks = {} game.Players.PlayerAdded:Connect(function(Player) for i, v in pairs(Owners) do if Player.Name == v then local Players = game:GetService("Players") local welcomePlayerEvent = Instance.new("RemoteEvent") welcomePlayerEvent.Parent = game.ReplicatedStorage welcomePlayerEvent.Name = "WelcomePlayerEvent" local function onPlayerAdded(player) welcomePlayerEvent:FireClient(player) end Players.PlayerAdded:Connect(onPlayerAdded) end end end)
Local Script Code
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local welcomePlayerEvent = ReplicatedStorage:WaitForChild("WelcomePlayerEvent") local playerGui = player:WaitForChild("PlayerGui") local ScreenGui = script.Parent.ScreenGui local function onWelcomePlayerFired() ScreenGui.Parent = playerGui end welcomePlayerEvent.OnClientEvent:Connect(onWelcomePlayerFired)
You are running the RemoteEvent in a wrap of two PlayerAdded events? It will absolutely not work because PlayerAdded event will never fire in PlayerAdded signal. It is surely complicated but it is redundant to do so, and it will not work.
You can consider putting the FireClient event outside, since you already have a player parameter in the first PlayerAdded event, you can just fire it directly with the parameter.
Also, server does not have Players.LocalPlayer. You are going to get it using PlayerAdded and get the parameter. Where you already have it so you can remove the line.
Going to the LocalScript, I've noticed a problem is that if you are not in the Owner table, you are going to yield the WaitForChild from the ReplicatedStorage, and never get a respond and return a warning.
Last problem, and this is from the LocalScript. You never assigned a parameter for player in the OnClientEvent function. Which will make an error "Arguments 1 missing or nil". To fix this, you need to assign the player parameter into the function. Also another problem is you are trying to clone ScreenGui into LocalPlayer? I believe you meant making the GUI clones to the player who have ran the RemoteEvent.
Server Script:
local Owners = {"SkyFume"} local Superadmins = {} local Admins = {} local Mods = {} local CustomRanks = {} game.Players.PlayerAdded:Connect(function(Player) for i, v in pairs(Owners) do if Player.Name == v then -- local Players = game:GetService("Players") This is redundant. It is located but never used. You can remove this if you want. local welcomePlayerEvent = game:GetService("ReplicatedStorage").welcomePlayerEvent welcomePlayerEvent:FireClient(Player) end end end)
Client Script:
local welcomePlayerEvent = ReplicatedStorage.welcomePlayerEvent local function onWelcomePlayerFired() local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local player = Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui") local ScreenGui = script.Parent.ScreenGui ScreenGui.Parent = playerGui end welcomePlayerEvent.OnClientEvent:Connect(onWelcomePlayerFired)