daulric
(daulric)
November 1, 2021, 6:54pm
#1
Ok so how to i implement datastore in a cash on kill script
This is my code if it will help
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function(Died)
local creator = Character.Humanoid:FindFirstChild("creator")
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator ~= nil and creator.Value ~= nil then
leaderstats.Points.Value = leaderstats.Points.Value + 10
end
end)
end)
end)
You’re asking for a complete system to be made for you.
daulric
(daulric)
November 1, 2021, 7:22pm
#3
Does DataSore:SetAttribute
store data?
NO, that changes the value of an attrubute. Which is like a custom property.
daulric
(daulric)
November 1, 2021, 7:31pm
#5
ok thanks man for the info!! I will try another method
daulric
(daulric)
November 1, 2021, 7:45pm
#6
i really need help. How do you implement datastore in the script above. i looked everywhere and even the link you sent. I still haven’t found the solution
daulric
(daulric)
November 1, 2021, 7:55pm
#7
This is the new script.
local DataSore = game:GetService("DataStoreService")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local points = Instance.new("IntValue")
points.Name = "Points"
points.Value = 0
points.Parent = leaderstats
player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function(Died)
local creator = Character.Humanoid:FindFirstChild("creator")
local leaderstats = creator.Value:FindFirstChild("leaderstats")
if creator ~= nil and creator.Value ~= nil then
leaderstats.Points.Value = leaderstats.Points.Value + 10 or DataSore:SetAsync(points)
end
end)
end)
end)
What should i add to make it save. (i really dont understand datastoreservice)