Hi, I've been making a keybind system for a game, and I'm using a RemoteFunction to fetch/save keybind data. However, it isn't detecting my InvokeServer calls. The odd thing is, it works like 1/6 of the time. You might notice the print("Hook") in the server script, and it never prints
This is part of my LocalScript that invokes the function
local Keybinds
repeat wait() -- I tried this to get the RemoteFunction to respond
spawn(function()
print("Trying For Data") -- Infinitly prints
Keybinds = ReplicatedStorage.Funky:InvokeServer("Keybinds")
end)
until Keybinds
This is the server script that is controlling the RemoteFunction (I don't know if it matters but I have multiple scripts listening to the same RemoteFunction)
local ds = game:GetService("DataStoreService"):GetDataStore("Keybinds","idlkfvjnh")
local cache = require(script.Cache)
function game.ReplicatedStorage.Funky.OnServerInvoke(plr,action,data)
print("Hook")
if action == "Keybinds" then
if not data then
print("Fetch")
local save = ds:GetAsync(plr.UserId)
if save then
return save
else
return game.HttpService:JSONEncode({"W","A","S","D"})
end
else
print("Data")
if #game.HttpService:JSONDecode(data) == 4 then
cache[plr.UserId] = {plr.UserId,data}
else
error("Keybind Localscript Did Not Send 4 Values")
end
end
end
end
while wait(8) do
for i,v in pairs(cache) do
ds:SetAsync(v[1],v[2])
print("Saved Cache Data For "..game.Players:GetNameFromUserIdAsync(v[1]))
table.remove(cache,i)
end
end

2 comments
function RemoteFunction.OnServerInvoke works too doesn't it
still doesn't work