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

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

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

✓ Accepted answer

Simple fix, Change:

game.ReplicatedStorage.RequestCode.OnServerInvoke = getcode()

to this

game.ReplicatedStorage.RequestCode.OnServerInvoke = getcode

3 comments

0

thanks for the help

0

hate it when a whole script is broken because of like two characters

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