It keeps telling me that Kills is not a valid member of Model "Players.MyName.leaderstats".
I know it is a valid member, so I dont know why this is happening. This is my leaderstats script:
local Players = game.Players local Template = Instance.new("BoolValue") Template.Name = "leaderstats" Instance.new("IntValue", Template).Name = "Kills" Instance.new("IntValue", Template).Name = "Deaths" Players.PlayerAdded:Connect(function(player) wait(1) local Stats = Template:Clone() Stats.Parent = player local Deaths = Stats.Deaths player.CharacterAdded:Connect(function(Character) Deaths.Value = Deaths.Value + 1 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)
I don't think anythings wrong with that. This is the code that is not working:(it is in a textbutton and it is supposed to give a sword)
player = game.Players.LocalPlayer backpack = player.Backpack local plr = game.Players.LocalPlayer plr:GetMouse().KeyDown:Connect(function(K) if K == "e" then local sword = game.Lighting.Tools.ClassicSword:Clone() ---- change "ClassicSword" to the name of your tool if player.leaderstats.Kills.Value >= 15 then ----- change 10 to the price of your tool and "Money" to whatever you named your Points for leaderboard player.leaderstats.Kills.Value = player.leaderstats.Kills.Value - 15 ----- change 10 to the price of your tool and "Money" to whatever you named your Points for leaderboard sword.Parent = backpack end end end) plr:GetMouse().KeyDown:Connect(function(F) if F == "x" then game.StarterGui.ShopGui.Shop.Visible = false end end)
I also wanted it so x closes the shop gui. Why is my code not working? (e also opens the shop if that helps at all.) All help is appreciated.
The issue with this is I had 2 leaderstats by accident, and they were clashing.