so i made a shop where you can sell tools
local script
event.OnClientEvent:Connect(function(player)
print(player)
talk.Visible = true
Yoption.MouseButton1Click:Connect(function()
sellitem(player)
end)
end)
serverscript
script.Parent.ClickDetector.MouseClick:Connect(function(player)
print(player)
event:FireClient(player)
end)
however what prints in the output isnt the player but instead it prints player on the server script and nil on the local script
ijmod
(kong)
#2
Using FireClient
takes in the parameter Player
, but this does NOT pass to the client.
So, for this code:
event.OnClientEvent:Connect(function(player)
Since you are not passing any additional arguments after the Player parameter on the server, it would just be:
event.OnClientEvent:Connect(function()
However, if you were to be passing more arguments to the client such as the code below:
event:FireClient(player, 100, 500)
Handling this would simply be:
event.OnClientEvent:Connect(function(num1, num2) --ignoring the Player parameter
print(num1, num2)
end)
--Output: 100 500
To put into shorter terms, when dealing with FireClient
, all the arguments AFTER the player parameter should be in the event.
4 Likes