I am writing a script that bans players from the, while also saving the reason, so it can be displayed to the player, anyway, loading the data goes fine, no errors... but when saving it, it give me this error: ServerScriptService.loadUserData:19: bad argument #2 to '?' (string expected, got Object)
.
The code that I am using is:
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() local userData = Instance.new("Folder", player) userData.Name = "userData" local banData = Instance.new("Folder", userData) banData.Name = "banData" local banReason = Instance.new("StringValue", banData) banReason.Name = "reason" banReason.Value = player:LoadString("banReason") end) game.Players.PlayerRemoving:connect(function(player) game.Players[player]:SaveString("banReason", player.userData.banData.banReason.Value) end)
Thanks!
bad argument #2 to '?' (string expected, got Object) means you indexed an value with the wrong type.This means that it should either be a string value not an object value or an object value not a string value