So here's ordinary script:
script.Parent.ClickDetector.MouseClick:Connect(function(player) game.ReplicatedStorage.RemoteBuy:FireServer() end)
When player(client) clicks it, script in serverScriptService listens and does something. It has been working normally, but now it gives me an Error saying FireServer can only be called from the client. But isn't player a client? Is it a bug?
Changing to FireClient and OnClientEvent will not work, because script is in ServerScriptService.
Thank's in advance!!!
It isnt a bug though a error of what script your actually calling it from, which is a from a Server script so it errors that :FireServer()
can only be called by the client which it means Local script. Naming the parameter of the MouseClick
event doesnt mean its on the client nor did you even use it. If you want to call the server you need to use it on a Local script
, but for server scripts you can call :FireClient(define player)
and :FireAllClients()
.
Just to mention, I'd use a sanity-check in case an exploiter can just mess up your game if there's no actual check (Do the checks from the server, not the client).
Also. Always use GetService() on services except for workspace.