Hello everybody! So i have a script in ServerScriptService that basically saves kills with a datastore in the leaderboard, However i want to make another leaderboard that gives you cash when you kill somebody with no save or datastore but it seems i can’t do it and everytime i try scripting it it breaks the original kill leaderboard script in ServerScriptService, So i wonder if somebody can be generous and give me a script for when you kill somebody and get cash in the leaderboard but it doesn’t save or help me at scripting it, And here is the saving kill leaderboard in the serverscriptservice:
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("MoneyStats")
game.Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local Kills= Instance.new("IntValue", Leaderstats)
Kills.Name = "Kills"
Kills.Value = 0
local Data = DataStore:GetAsync(Player.UserId)
if Data then
Kills.Value = Data.Kills
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId, {
["Kills"] = Player.leaderstats.Kills.Value;
})
end)
local Players = game.Players
local Template = Instance.new 'BoolValue'
Players.PlayerAdded:connect(function(Player)
local Stats = Template:Clone()
Stats.Parent = Player
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:FindFirstChild "Humanoid"
if Humanoid then
Humanoid.Died:connect(function()
for i, Child in pairs(Humanoid:GetChildren()) do
if Child:IsA('ObjectValue') and Child.Value and Child.Value:IsA('Player') then
local Killer = Child.Value
if Killer:FindFirstChild 'leaderstats' and Killer.leaderstats:FindFirstChild "Kills" then
local Kills = Killer.leaderstats.Kills
Kills.Value = Kills.Value + 1
end
return
end
end
end)
end
end)
end)
-
What do you want to achieve?
I want to make another leaderboard that gives your cash in the leaderboard whenever you kill a player with no datastore or save and doesn’t break the kill script in Serverscriptservice. -
What is the issue?
Every time i try scripting it it breaks the Original script in serverscriptservice By either showing only the cash leaderboard or breaks the kill script in serverscriptservice and doesn’t work. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried scripting the script but didn’t work and i also did look for solutions on the developer hub but didn’t find any.