I am trying to make a saving collectible system by using a Boolean Value called 'regularFound'. I put the value in StarterCharacterScripts, and I can collect the item just fine. However, when I try to save the value with a script, I get the error message attempt to index nil with 'regularFound'. Here is my code:
local store = game:GetService("DataStoreService")
local datastore = store:GetDataStore("Data")
game.Players.PlayerAdded:Connect(function(plr)
plr.Character.regularFound.Value = datastore:GetAsync(plr.UserId.. "value")
end)
game.Players.PlayerRemoving:Connect(function(plr)
datastore:SetAsync(plr.UserId.. "value", plr.Character.regularFound)
end)
Any idea why studio thinks that 'regularFound' does not exist?
