local DataStoreService = game:GetService("DataStoreService")
local Magic = DataStoreService:GetDataStore("Magic") -- These will create 2 new data stores called HasMagic and HasMagic as they do not exist yet
local HasMagic = DataStoreService:GetDataStore("HasMagic") --
game.Players.PlayerAdded:connect(function(plr)
local key = "user_"..plr.userId -- UserId's are unique and stay the same for each player so that's why I am using this (it will also account for name changes)
local Magic = Instance.new("StringValue",plr)
Magic.Name = "Magic"
Magic.Value = Magic:GetAsync(key) or "" -- Having problems here...
local HasMagic = Instance.new("BoolValue",Magic)
HasMagic.Name = "HasMagic"
HasMagic.Value = HasMagic:GetAsync(key) or 1 -- Loads the value of the HasMagic or makes it 1 if they haven't played before.
HasMagic.Changed:connect(function() HasMagic:SetAsync(key, HasMagic.Value) end) -- These save the HasMagic and HasMagic when their Magic update
Magic.Changed:connect(function() Magic:SetAsync(key, Magic.Value) end)
end)
I would like your help thanks! -- Ciyu123

1 comment
Any error messages?