Script not detecting folder

You aren’t passing the player argument to the function at all, so the player variable there is nil, also the event should be PlayerRemoving not PlayerAdded!

Instead, you should do:

game.Players.PlayerRemoving:Connect(function(player)	savedata(player) --player is passed to the function! end) 

or even better:

game.Players.PlayerRemoving:Connect(savedata) 

which will automatically pass all the event parameters(in this case, the player) to the savedata function.

Also don’t separate values with semicolons, this is a syntax error(I think), instead separate them with commas:

local saveTable = {	player.SwordFolder.BegPunch.Value, --a comma not a semicolon!	player.SwordFolder.IntPunch.Value } 

Other issues with your code include:

  1. saveTable isn’t a dictionary, for player-related data dictionaries are ideal and caring about space isn’t needed because datastores offer 4MB of space per key.
  2. you aren’t fetching the data when the player is added, so their data will start from nothing again and be saved as is so you basically erase their data every time they join the game.
  3. you should save data when the player leaves, not every time the in-game values change, else you will be rate limited by the Roblox datastores API.

Also, your code has a lot of more complicated data store issues but for those open-source libraries such as ProfileService exist. In general, it’s a good practice not to reinvent the wheel, especially when messing with important things like player data.

Lastly, due to a large number of errors in your code, I assume it may be AI-generated, don’t trust AI for serious issues such as data stores.