To start, My script is supposed to put a "(Name) joined the game" Message in the chat
I have a script a local script and a remote event for this,
In Replicatedstorage i have ReplicatedStorage.Events(a folder).Added(a remote event)
local events = game.ReplicatedStorage.Events local Players = game:GetService("Players") game.Players.PlayerAdded:Connect(function(plr) events.Added:FireAllClients() end)
And my local script for putting the message in chat: (Located in startergui)
local events = game.ReplicatedStorage.Events local starterGui = game.StarterGui local Players = game:GetService("Players") events.Added.OnClientEvent:Connect(function(plr) starterGui:SetCore("ChatMakeSystemMessage",{ Text = plr.Name.." has arrived to the island"; Color = Color3.fromRGB(255,0,0); Font = Enum.Font.Creepster; FontSize = Enum.FontSize.Size32; }) end)
My error message is :
Players.Goblinc0re.PlayerGui.Message:7: attempt to index nil with Name
(goblinc0re is my username)
If you could provide any help i would appreciate it
Well, what you are doing is using FireAllClients
but not passing any information, i.e., you are adding a variable plr
, which is nil
, as no information is passed.
To simply fix the issue :
-- ServerScript [Line 5] events.Added:FireAllClients(plr) -- Here, it will pass the plr instance
More info :
RemoteEvents and RemoteFunctions
Lemme know if it helps!