Hello, this is my 3rd or 4th day scripting, and I feel like I am lost. I have received little to no teaching through the discord on this subject, and no one has reviewed my script to make sure I have understood this. YouTube videos haven't helped me on this subject either, as I have tried to understand their script work and I feel like it hasn't paid off the way I wanted to. I will post the 2 scripts I made here: Money Data Storage Save Script:

local DataStorage = game:GetService("DataStoreService")
local PersonalDataStorage = DataStorage:GetDataStore("DataStorageService")




game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("BoolValue",player)
	stats.name = "leaderstats"
	
	local Money = Instance.new("IntValue",stats)
	Money.name = "Money"
	
	local Leaderboard = Instance.new("Folder")
	Leaderboard.Name = "Leaderboard"
	Leaderboard.Parent = player
	
	local Money = Instance.new("IntValue")
	Money.Name = "Money"
	Money.Parent = Leaderboard
	
	local data
	local success, errormessage = pcall(function()
		data = PersonalDataStorage:GetAsync(player.UserId.."Money")
	end)
		
	if success then
		Money.Value = data
	else
		print("There was a problem retreiving your Money.")
		warn(errormessage)
	end
end)


game.Players.PlayerRemoving:Connect(function(player)
	
	local success, errormessage = pcall(function()
		PersonalDataStorage:SetAsync(player.UserId.."-Money",player.Leaderboard.Money.Value)
	end)
	
	if success then
		print("Player's Data has been saved.")
	else
		print("Error occured while trying to save Player Data.")
		warn(errormessage)
	end
end)

For this one I used AlvinBlox's youtube videos to try and understand how a data storage works. I also used one of his earlier videos to define the "leaderstats" so that "Money" should show up on the player list so their money should be displayed next to their player name on the leaderboard. The problem is, in "Output" in the studio, is not showing any errors, and it is not working.

Model Value Data Storage:

local DataStorage = game:GetService("DataStoreService")
local PersonalDataStorage = DataStorage:GetDataStore("DataStorageService")

game.Players.PlayerAdded:Connect(function(player)
	local Folder = Instance.new("Folder")
	Folder.name = "Owned_Cars"
	Folder.Parent = player
	
	local data
	local success, errormessage = pcall(function()
		data = PersonalDataStorage:GetAsync(player.UserId.."Owned_Cars"):GetChildren()
		end)
			
		if success then
			Folder.Value = data:GetChildren()
		
		else
			
			print("There was a problem retreiving your vehicles.")
			warn(errormessage)
		end
end)

game.Players.PlayerRemoving:Connect(function(player)
	
	local success, errormessage = pcall(function()
		PersonalDataStorage:SetAsync(player.UserId.."Owned_Cars",player.Folder.GetChildren())
		end)
	if success then
		print("Player Vehicles have been successfully saved.")
	
	else
		
		print("There has been an error regarding player vehicles being saved.")
		warn(errormessage)
	end
end)

With this script, I am trying to have the models bought by the player, saved so when they rejoin, they don't have to buy the models again. The models aren't directly saved though, it just saves the value of the model in question under their ID, so when they rejoin, they don't have to buy it again. This is a modified version of the previous script.

P.S. I have received comments about how I should "thoroughly understand the easier stuff" before I tackle stuff like this. I find that mentality very limiting. If you're not willing to teach me because I am an amateur, or a novice when I am trying to understand a concept, then you're a poor teacher, or not a teacher at all. I'd appreciate a valid teaching response so I can understand these concepts, and use them. How can one learn the basics, if the teacher isn't willing to teach the knowledge seeking.

4 comments

0

I don't really recommend making stuff from tutorials. I recommend watching videos about one speciffic thing and then getting all of that in one script. I recommend this playlist, he explains everything very well. I learned from it, you can too. :) https://www.youtube.com/playlist?list=PLhieaQmOk7nIfMZ1UmvKGPrwuwQVwAvFa

0

Sorry if you think I am a bad teacher, but I do agree with people who says that you should start at the level 1 stuff, because I started scripting about 1 - 2 months ago, and I started by watching AlvinBlox's beginner scripting tutorials from episode 1. For example, if you are trying to build a house, you have to build the bottom before you can build the second floor and roof, same as scripting.

0

Also, I can teach you too if you want.

0

@zamd157 I'd appreciate it if you teached me 1 on 1