Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

6 comments

0

I understand now thanks. Now I recalled when I changed it to Server script , but didn't really remember it till now.

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

0

then your doing something wrong

0

Now problem is not in Server-client relationship, but with clickdetector, it doesn't even detect mouseclick

0

then post a question

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.

1 comment

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?

This discussion is preserved as it was. New answers, comments, and votes are closed.