Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Proper way to call FireServer. Bug Alert!!!?

Asked by 5 years ago

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!!!

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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().

0
I understand now thanks. Now I recalled when I changed it to Server script , but didn't really remember it till now. GooierApollo664 183 — 5y
0
Thing is that it does absolutely nothing now. I changed it to local script and am FiringServer from it but nothing happens, it doesn't even print("Hay") in mouseClick funtion GooierApollo664 183 — 5y
0
then your doing something wrong User#23365 30 — 5y
View all comments (2 more)
0
Now problem is not in Server-client relationship, but with clickdetector, it doesn't even detect mouseclick GooierApollo664 183 — 5y
0
then post a question User#23365 30 — 5y
Ad
Log in to vote
0
Answered by
angeI1001 123
5 years ago

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.

0
How do I sanity-check? but I don't understand why is it necessary, because I have filtering-enabled on and doing this particular action with remoteEvent. Is it that RemoteEvents doesn't really prevents exploiters? GooierApollo664 183 — 5y

Answer this question