--SERVERSCRIPT
local RemoteEvent = game:GetService("ReplicatedStorage").Notify
script.Parent.Triggered:Connect(function(Player)
RemoteEvent:FireClient(Player)
end)
--LOCALSCRIPT
local RemoteEvent = game:GetService("ReplicatedStorage").Notify
RemoteEvent.OnClientEvent:Connect(function(Player)
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "123",
Text = "abc",
Duration = 5,
})
end)
Dont forget to put your LocalScript to StarterPlayerScripts or StarterCharacterScripts. Otherwise it wont work because ReplicatedFirst is essential to game’s start. Like loading screen and etc.
EDIT: Also dont forget to put your RemoteEvent to ReplicatedStorage.
For some reason, it didn’t, work… but I inserted some prints to check out the problem… and here is what I found out (I still need help on how to solve it)
--LOCALSCRIPT
local RemoteEvent = game:GetService("ReplicatedStorage").Notify
RemoteEvent.OnClientEvent:Connect(function(Player, Code)
print(Player)
print(Code)
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "123",
Text = "abc",
Duration = 5,
})
end)
--SERVERSCRIPT
local RemoteEvent = game:GetService("ReplicatedStorage").Notify
script.Parent.Triggered:Connect(function(Player)
print("Triggered")
RemoteEvent:FireClient(Player, 5)
end)
OUTPUT:
So, when the localscript should print the player, it prints the code… and when it should print the code, it prints “nil”
--LOCALSCRIPT
local RemoteEvent = game:GetService("ReplicatedStorage").Notify
RemoteEvent.OnClientEvent:Connect(function(Code)
local Player = game.Players.LocalPlayer --If needed, not necessary in this case
game:GetService("StarterGui"):SetCore("SendNotification", {
Title = "123",
Text = "abc",
Duration = 5,
})
end)
Just removed Player form OnClientEvent function
No changes in ServerScript
Thanks for everyone that replied my post! It really helped!