so me and my friend tried making a sword fighting game, and i decided to make a leaderstats for KOs and Wipeouts. I'm really new to coding but i've done leaderstats before and they worked pretty much fine. this script however doesnt, and it didnt give me any errors. so i dont know what to do
script. game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = plr local kos = Instance.new("Folder") kos.Name = "KOs" kos.Parent = plr local wo = Instance.new("Folder") wo.Name = "Wipeouts" wo.Parent = plr plr.CharacterAdded:Connect(function(char) local humanoid repeat humanoid = char:FindFirstChild("Humanoid") wait() until humanoid humanoid.Died:Connect(function() wo.Value = wo.Value + 1 local tag = humanoid:FindFirstChild("creator") if tag then local killer = tag.Value if killer then killer.leaderstats.kos.Value = killer.leaderstats.kos.Value + 1 end end end) end)
end)
The problem is your leaderstats needs to have IntValues
not Folders, you can't make a folder a value :
23 wo.Value = wo.Value + 1 -- attempts to set a folder value
do this for leaderstats:
game.Players.PlayerAdded:Connect(function(plr) local stats = Instance.new("Folder") -- Folder for leaderstats stats.Name = "leaderstats" stats.Parent = plr local kos = Instance.new("Intvalue") -- NUMBER VALUE 1 kos.Name = "KOs" kos.Parent = stats local wo = Instance.new("IntValue") -- NUMBER VALUE 2 wo.Name = "Wipeouts" wo.Parent = stats plr.CharacterAdded:Connect(function(char) local humanoid repeat humanoid = char:FindFirstChild("Humanoid") wait() until humanoid humanoid.Died:Connect(function() wo.Value = wo.Value + 1 local tag = humanoid:FindFirstChild("creator") if tag then local killer = tag.Value if killer then killer.leaderstats.kos.Value = killer.leaderstats.kos.Value + 1 end end end) end) end)
You've added not 1 folder, but 3 folders. For leaderstats, I recommend putting only one folder, and 2 Values (whatever they are, Bool, Number, Int, etc.) Folder does not have a property named 'Value'. Change kos
and wo
to intvalues.
game.Players.PlayerAdded:Connect(function(plr) local stats = Instance.new("Folder") stats.Parent = plr stats.Name = "leaderstats" local kos = Instance.new("IntValue") kos.Parent = stats kos.Name = "KOs" local wo = Instance.new("IntValue") wo.Parent = stats wo.Name = "Wipeouts" end)