Hey, so saw from similar threads people ask for the specific code involved, so figured I’d put it here from the get go. I have no idea about scripting, this is a mix of 3/4 scripts I have jumbled together and up until I added the part marked with ** it all worked fine.
I have added an ‘end’ and removed an ‘end’ and the problem doesn’t resolve itself. Kind of at a loss.
Any help in where it’s gone wrong would be appreciated. Thanks!
game.Players.PlayerAdded:Connect(function(p)
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls
local cash = Instance.new("IntValue")
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls
**local KillsRequirement = 10
Kills.Changed:Connect(function(NewValue)
if NewValue >= KillsRequirement then
print(p.Name.." has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value
end**
local crates = game.ReplicatedStorage:WaitForChild(“Crates”)
game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
if crates:FindFirstChild(crateType) then
local price = crates[crateType].Price.Value
if plr.leaderstats.Aureus.Value >= price then
plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
local unboxableWeapons = crates[crateType]:GetChildren()
local chosenWeapon
repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
wait(crateTime + 1)
chosenWeapon:Clone().Parent = plr.Backpack
end)
game.Players.PlayerAdded:Connect(function(p)
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls
local cash = Instance.new("IntValue")
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls
end)
local KillsRequirement = 10
Kills.Changed:Connect(function(NewValue)
if NewValue >= KillsRequirement then
print(p.Name.." has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value
end
end)
local crates = game.ReplicatedStorage:WaitForChild("Crates")
game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
if crates:FindFirstChild(crateType) then
local price = crates[crateType].Price.Value
if plr.leaderstats.Aureus.Value >= price then
plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
local unboxableWeapons = crates[crateType]:GetChildren()
local chosenWeapon
repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
wait(crateTime + 1)
chosenWeapon:Clone().Parent = plr.Backpack
end
end
end)
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls
local cash = Instance.new("IntValue")
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls
local KillsRequirement = 10
Kills.Changed:Connect(function()
if NewValue >= KillsRequirement then
print(p.Name.." has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value
end
local crates = game.ReplicatedStorage:WaitForChild("Crates")
game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
if crates:FindFirstChild(crateType) then
local price = crates[crateType].Price.Value
if plr.leaderstats.Aureus.Value >= price then
plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
local unboxableWeapons = crates[crateType]:GetChildren()
local chosenWeapon
repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
wait(crateTime + 1)
chosenWeapon:Clone().Parent = plr.Backpack
end
end
end)
end)
game.Players.PlayerAdded:Connect(function(p)
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls
local cash = Instance.new("IntValue")
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls
local KillsRequirement = 10
Kills.Changed:Connect(function()
if NewValue >= KillsRequirement then
print(p.Name.." has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value
end
local crates = game.ReplicatedStorage:WaitForChild("Crates")
game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
if crates:FindFirstChild(crateType) then
local price = crates[crateType].Price.Value
if plr.leaderstats.Aureus.Value >= price then
plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
local unboxableWeapons = crates[crateType]:GetChildren()
local chosenWeapon
repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
wait(crateTime + 1)
chosenWeapon:Clone().Parent = plr.Backpack
end
end
end)
end)
end)
im gonna guess the NewValue variable is the kills value
game.Players.PlayerAdded:Connect(function(p)
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("CrateServer")
local ls = Instance.new("Folder")
ls.Name = "leaderstats"
ls.Parent = p
local Kills = Instance.new("IntValue")
Kills.Name = "Kills"
Kills.Value = 0
Kills.Parent = ls
local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Parent = ls
local cash = Instance.new("IntValue")
cash.Name = "Aureus"
cash.Value = 0
cash.Parent = ls
local KillsRequirement = 10
Kills.Changed:Connect(function()
local NewValue = Kills.Value
if NewValue >= KillsRequirement then
print(p.Name.." has levelled up! Current Level: ", Level.Value)
Kills.Value = 0
Level += 1
KillsRequirement *= Level.Value
end
local crates = game.ReplicatedStorage:WaitForChild("Crates")
game.ReplicatedStorage.CrateRE.OnServerEvent:Connect(function(plr, crateType, crateTime)
if crates:FindFirstChild(crateType) then
local price = crates[crateType].Price.Value
if plr.leaderstats.Aureus.Value >= price then
plr.leaderstats.Aureus.Value = plr.leaderstats.Aureus.Value - price
local unboxableWeapons = crates[crateType]:GetChildren()
local chosenWeapon
repeat chosenWeapon = unboxableWeapons[math.random(#unboxableWeapons)] wait() until chosenWeapon:IsA("Tool")
game.ReplicatedStorage.CrateRE:FireClient(plr, chosenWeapon)
wait(crateTime + 1)
chosenWeapon:Clone().Parent = plr.Backpack
end
end
end)
end)
end)
Marking as solution because it solved the original problem. Unfortunately, while no longer broken as such, when players reach the KillsRequirement, Kills reset to 0 and Level does not increase.