Hello, currently I am trying to pass some data through a :FireClient() event. However, when I output it on the client side it returns nil, when it shouldnt be.
Server:
local Event = ReplicatedStorage:FindFirstChild('Events'):FindFirstChild('GUI'):WaitForChild('EnableSelectGui')
local tochange = script.Parent.Name
print (tochange)
if Event then
Event:FireClient(player, tochange)
end
Client:
ClientEvent.OnClientEvent:Connect(function(player, tochange)
print (tochange)
end)
Output:
Server = Part
Client = nil
You don’t need to specify the “player” variable in the client script.
Try this.
ClientEvent.OnClientEvent:Connect(function(tochange)
print (tochange)
end)
4 Likes
As @ArchetypalCoder stated:
OnClientEvent does not use have the player as a default argument (unlike the server’s OnServerEvent), meaning:
ClientEvent.OnClientEvent:Connect(function(tochange)
print(tochange)
end)
should work.
However if you do wish to fire the Player to every client you would do:
Event:FireAllClients(Player, tochange)
while keeping the player argument on the client event connection, of course.
2 Likes
I see, thanks for clarifying this.