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

How can i fix a local function firing at the start of a server?

Asked by 5 years ago

In my game i have a case system and the server script has a local function within it that requires a player value given by the OnServerInvoke shown below

This is for an anti-exploit

game.ReplicatedStorage.RequestCode.OnServerInvoke = getcode()

Here is the function

local function getcode(player)
    if player.CasesOpened.Value <= (player.TimePlayed.Value/4)-1 then
        return secretcode
    else
        player.Exploiter.Value = true
    end
    return nil
end 

However this function seems to fire right at the start of the server and it causes the system to break completely. I checked for anything else that could be firing the invokeserver request but only cases (what it was meant for, not fired at the start of a server) and i've checked for any getcode() calls in the script but only the OnServerInvoke request has it

Debugging also doesn't help here, i don't like when people just say DEBUG

DEBUG DOESN'T ALWAYS HELP

So please, is there some way i can get it to stop firing on server startup?

1 answer

Log in to vote
1
Answered by
oftenz 367 Moderation Voter
5 years ago

Simple fix, Change:

game.ReplicatedStorage.RequestCode.OnServerInvoke = getcode()

to this

game.ReplicatedStorage.RequestCode.OnServerInvoke = getcode
0
Check out Server Invoking if you want more info: https://developer.roblox.com/en-us/api-reference/callback/RemoteFunction/OnServerInvoke oftenz 367 — 5y
0
thanks for the help mm1678YT 80 — 5y
0
hate it when a whole script is broken because of like two characters User#25069 0 — 5y
Ad

Answer this question