Hello, I'm implementing a code system to my game but when I trigger my RemoteFunction and access it in the server it does nothing
Here are the scripts
Local script (pressing a Gui button)
local button = script.Parent button.MouseButton1Click:Connect(function() local event = game.ReplicatedStorage.CodeRemoteFunction local inputCode = script.Parent.Parent.TextBox.Text local result = event:InvokeServer(inputCode) if result == "Accepted" then inputCode = "Code succesfully redeemed!" else inputCode = "Code Invalid or already redeemed" end end)
Server Script
local codesModule = require(game.ServerScriptService.CodesModule) game.ReplicatedStorage.CodeRemoteFunction.OnServerInvoke = function(player, input) if codesModule[input] then codesModule[input](player) return "Accepted" else return "Rejected" end end
I think you write wrong name or you named remote event wrong or you Or you just didn't added local to part of this script :
local codesModule = require(game.ServerScriptService.CodesModule) ------------------------------------------ game.ReplicatedStorage.CodeRemoteFunction.OnServerInvoke = function(player, input) ------------------------------------------ if codesModule[input] then codesModule[input](player) return "Accepted" else return "Rejected" end end
The correct script is this :
local codesModule = require(game.ServerScriptService.CodesModule) local game.ReplicatedStorage.CodeRemoteFunction.OnServerInvoke = function(player, input) if codesModule[input] then codesModule[input](player) return "Accepted" else return "Rejected" end end