See thats my other script without the leaderstats killing script its not the other scripts bothering it. I only changed the datastore
Since you disabled the script that would be like kill a player for gold, maybe it changed some stuff in the leaderstats? Could you show the script you disabled?
did you put three more end)s in it
Okay let me explain thats the script that works for sure and thats the script without the killing script, but I want to add the killing script somehow I want players to get money when the ykill
local DataStore2 = require(1936396537)
DataStore2.Combine("MasterKey","Gold")
game.Players.PlayerAdded:Connect(function(plr)
local dataGold = DataStore2("Gold", plr)
local folder = Instance.new("Folder",plr)
folder.Name = "leaderstats"
local gold = Instance.new("IntValue", folder)
gold.Name = "Gold"
if dataGold:Get() ~= nil then
gold.Value = dataGold:Get()
else
gold.Value = 100
end
gold.Changed:Connect(function()
dataGold:Set(gold.Value)
end)
end)
maybe you can put it in another script
You mean my kill script how I tried using my whole kill script inside another script and named a new leaderstats named gold again but it lags it.
you can put the kill script in a different script you dont need to put the leaderstats with it
That is what I mean but how would I refer to teh datastore 2? Can you help me fix?
Just change the leaderstat value and it will save because you set it before so it will save when changed
game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder",player)
folder.Name = "leaderstats"
local currency = Instance.new("IntValue",folder)
currency.Name = "Gold"
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local tag = character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local stats = tag.Value:WaitForChild("leaderstats")
stats["Gold"].Value = stats ["Gold"].Value + 150
end
end
end)
end)
end)
That is my kill script for anotehr script as you said how would I fix it?
Take only the humanoid died part
So how would I use that to make it be able to relate to DataStore2 Can you like show me?
ok so in your datastore script it saves the data when the value is changed so just update the value amd it will save leaderstats value
Okay but its a new script so it changes how would I fix my kill scrip?
put your kill script in the startercharacter scripts
So dont erase anything inside it right now?
Make sure you are only moving the kill script and not the datastore script too
okay wait but the problem is for my kill script I made a new leaderstats thats named gold so it might get confused