function Controller:GetKeybinds(retries, delay)
retries = retries or 3
delay = delay or 0.1
local data
for attempt = 1, retries do
data = Remotes.getKeybinds:InvokeServer(Player)
if data and data.Keybinds then
break
end
warn("Keybinds missing from server, retrying... attempt", attempt)
task.wait(delay)
end
if not data or not data.Keybinds then
warn("Failed to get keybinds from server after", retries, "attempts")
return self.Keybinds
end
local newKey = data.Keybinds.BodycamActivationKey
if typeof(newKey) ~= "EnumItem" then
warn("Server sent invalid keybind:", newKey)
return self.Keybinds
end
if not self.Keybinds then
self.Keybinds = data.Keybinds
print("Initial keybinds cached:", newKey)
return self.Keybinds
end
if self.Keybinds.BodycamActivationKey ~= newKey then
print("Keybind changed from", self.Keybinds.BodycamActivationKey, "to", newKey)
self.Keybinds = data.Keybinds
end
return self.Keybinds
end
Server Side Function:
function DataManager.GetKeybinds(player)
if typeof(player) ~= "Instance" or player.Parent ~= game.Players then
warn("[Keybinds] Invalid player passed:", player)
return {}
end
local profile = DataManager.Profiles[player]
if not profile then
warn("[Keybinds] No profile found for player:", player.Name)
return {}
end
if not profile.Data then
warn("[Keybinds] Profile missing Data table for:", player.Name)
return {}
end
local keybinds = profile.Data.Keybinds
if typeof(keybinds) ~= "table" then
warn("[Keybinds] Invalid keybinds table for:", player.Name)
return {}
end
print(keybinds)
return keybinds
end
Have you checked the contents that the server is returning? There is a chance that your keys within your profile data table is not the exact case you want to have (e.g. it may be called “Keys”, or “keybinds”, etc. - so then when you try to do profile.Data.Keybinds, it doesn’t work as a result)…
I think it might be to with your check for data and data.Keybinds within your loop - from my understanding of Luau, you’re asking, on the client-side, that the data exists and within it, there is a key called “Keybinds” which you’re trying to check exists, but it doesn’t because you’ve already returned “data.Keybinds” on the server-side. As a result, it doesn’t break the loop as it should.
Then, your checks for no data OR no data.keybinds should be changed to no data AND no data.Keybinds will always return true to the condition (since there is data, but there is no data.Keybinds) meaning it never returns what it should.