aced_jkl
(aced_jkl)
October 28, 2021, 5:18pm
#1
local plr = game.Players.LocalPlayer
local DataStore = game:GetService("DataStoreService")
local TextService = game:GetService("TextService")
return function (context, target, text)
game:GetService("ReplicatedStorage").Remotes.Notification:FireClient(target, text, plr.Name.." - DM!")
return ("Command executed.")
end
Here is the error!
Vocruse
(Vocrus)
October 28, 2021, 5:23pm
#2
Is this in a module script or a local script?
aced_jkl
(aced_jkl)
October 28, 2021, 5:24pm
#3
This is a module script, that I have put it in.
Dyzody
(Dyzody)
October 28, 2021, 5:25pm
#4
Put it in starterplayerscripts.
Vocruse
(Vocrus)
October 28, 2021, 5:27pm
#5
yeah, make sure to put it inside the player
aced_jkl
(aced_jkl)
October 28, 2021, 5:28pm
#6
Then it would not work as it would be taken out of the commands folder.
Vocruse
(Vocrus)
October 28, 2021, 5:28pm
#7
So where is it currently stored? It’s the only way you can reference localplayer
The issue appears to be with plr.Name
, meaning plr
is nil
. What does the Roblox wiki say about Players.LocalPlayer
?
bnxDJ
(bnx)
October 28, 2021, 5:49pm
#9
https://developer.roblox.com/en-us/api-reference/property/Players/LocalPlayer
This property is only defined for LocalScript
s (and ModuleScript
s required by them), as they run on the client. For the server (on which Script
objects run their code), this property is nil
.
regexman
(reg)
October 28, 2021, 6:03pm
#10
wow, simple solution, local scripts can’t fire clients, only to server, instead handle the notification in the local script
You can’t reference “game.Players.LocalPlayer” inside a server script, instead get the player instance in some other way like from a fired “PlayerAdded” event etc. then use the player instance to get the name and then call FireClient() to fire the client.