Hello everyone i am trying to make so that when you press a button it passes a parameter of the player and the button to another script. It's working in studio altough not when playing on a server ingame. I don't know what i have done wrong. The error i get from the command console is:

"FireClient can only be called from the server".

Local Script that passes the arguments and triggers the event:

script.Parent.MouseButton1Click:connect(function(plr)
	game.Workspace.Shop_Script.RemoteEvent:FireClient(plr,script.Parent, script.Parent.Parent.Parent.Parent.Parent.Parent)
end)

my event:

script.RemoteEvent.OnClientEvent:connect(function(par, plr)
--My code
end)

Anyone know what i have done wrong?

Help would be really appreciated, thanks!

4 comments

0

The error explains itself. you are using FireClient in a local script.

0

Yes, :FireClient() can only be called on server since you're firing an event from client side. That's where OnClientEvent function responds on the client side. :FireServer() is on client, since you're trying to fire from server respectively. OnServerEvent function is now on server side, since it's responding to :FireServer()

0

Try and practice this as much as you can, that way you get used to it.

0

Ok, thanks i solved it now!