Error with datastore: Needing feedback

Hello, I’m currently trying to make a game with datastore saving systems. I used a youtube tutorial but there seems to be an error, can anyone help?

local players = game:GetService("Players")
local dataStores = game:GetService("DataStoreService")
local playerCoinsDataStore = dataStores:GetDataStore("PlayerCoins")

players.PlayerAdded:Connect(function(plr)
	
	local PlayerCoins = Instance.New('IntValue')
	PlayerCoins.Name = "PlayerCoins"
	PlayerCoins.Parent = plr

Here’s the output error
ServerScriptService.Script:7: attempt to call a nil value
(The script is inside ServerScriptService as shown in the video
(If you want the video the link is below)

It’s because you capitalized Instance.New(), do Instance.new() instead.
local PlayerCoins = Instance.new('IntValue')

local players = game:GetService("Players")
local dataStores = game:GetService("DataStoreService")
local playerCoinsDataStore = dataStores:GetDataStore("PlayerCoins")

players.PlayerAdded:Connect(function(plr)
	
	local PlayerCoins = Instance.new('IntValue')
	PlayerCoins.Name = "PlayerCoins"
	PlayerCoins.Parent = plr
end)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.