User settings, how?

That looks good! Remember to get the client to unpack it and apply it.
You might want to save player data when they leave so it doesn’t only save on autosave.

You might also want to add in Dos/DDoS protection on your remote.

local cooldowns = {}

local function OnSettingReceived(plr: Player, setting: string, value: any)
    if cooldowns[player.Name] then plr:Kick("Don't try to crash the server. That's not very nice.") return nil end
    cooldowns[player.Name = true]

    --the rest of the code for your function. Just remember that if you early return (return before the end of the function) reset their cooldown.

    task.wait(3)
    cooldowns[player.Name] = nil
end

[details = “Other kind of not related to that bits”]
[details = “bit 1”]

  1. I assume you used a function in the middle because other code happens there? If not, just connect InitializePlayerData directly to the Players.PlayerAdded event.
  2. You forgot to pass the player as parameter…
    [/details]
    [details = “bit 2”]
    I noticed when you define functions, you just do like:
function foo()
end

instead of like:

local function foo()
end

I just wanted to let you know that if you use global (no local keyword) function defining in your LocalScripts you should change it to use the local keyword because otherwise exploiters can access those functions. They can change them, modify them, do whatever they want to them. They have this function called getsenv() (get script environment) which returns all the globals available to the script.

If you try this code, you can see what I mean:

function foo()
    print("function called.")
end

foo() --> "function called"
getfenv().foo() --> "function called"
getfenv().foo = function()
    print("Exploiters can modify your functions.")
end

getfenv().foo() --> "Exploiters can modify your functions"
foo() --> "Exploiters can modify your functions"

Don’t worry, this won’t apply to settings.SettingChanged = function because you used the local keyword when requiring the module.
[/details]
sorry i keep talking about unrelated things lol
[/details]

1 Like