How to change folder value of players

I made a script on the server that is fired from a localscript, it should change the value of a boolvalue in a folder under each player. I already made a script wich add the folder and the boolvalue and it works because I can see it under each player in the players tab.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
print(player)
game.Players:FindFirstChild(player).SaveSettings.DarkMode.Value = true
end)

Now I just want to change the boolvalue but everytime I try, I get this error: ServerScriptService.changeSettings:3: attempt to index nil with ā€˜SaveSettingsā€™

How do I change the script that it finds the player, in the output from the print(player) I get the right player name

OnServerEvent Already returns the player object, So saying game.Players:FindFirstChild(player) will return nil, hence the error ā€œattempt to index nil with ā€˜SaveSettingsā€™ā€

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
print(player)
player.SaveSettings.DarkMode.Value = true
end)
3 Likes
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
   player.SaveSettings.DarkMode.Value = true
end)
1 Like

player is the actual player instance, not the name. To fix this, index their Name property.

game.Players:FindFirstChild(player.Name).SaveSettings.DarkMode.Value = true

wauw thank you! and also the rest of you guys, I thought it was just a string with the player name because of the output