Kills is not a part of leaderstats glitch?
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:
01 | local Players = game.Players |
03 | local Template = Instance.new( "BoolValue" ) |
04 | Template.Name = "leaderstats" |
06 | Instance.new( "IntValue" , Template).Name = "Kills" |
07 | Instance.new( "IntValue" , Template).Name = "Deaths" |
09 | Players.PlayerAdded:Connect( function (player) |
11 | local Stats = Template:Clone() |
13 | local Deaths = Stats.Deaths |
14 | player.CharacterAdded:Connect( function (Character) |
15 | Deaths.Value = Deaths.Value + 1 |
16 | local Humanoid = Character:FindFirstChild( "Humanoid" ) |
18 | Humanoid.Died:connect( function () |
19 | for i, Child in pairs (Humanoid:GetChildren()) do |
20 | if Child:IsA( "ObjectValue" ) and Child.Value and Child.Value:IsA( "Player" ) then |
21 | local Killer = Child.Value |
22 | if Killer:FindFirstChild( "leaderstats" ) and Killer.leaderstats:FindFirstChild "Kills" then |
23 | local Kills = Killer.leaderstats.Kills |
24 | Kills.Value = Kills.Value + 1 |
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)
01 | player = game.Players.LocalPlayer |
02 | backpack = player.Backpack |
03 | local plr = game.Players.LocalPlayer |
05 | plr:GetMouse().KeyDown:Connect( function (K) |
07 | local sword = game.Lighting.Tools.ClassicSword:Clone() |
09 | if player.leaderstats.Kills.Value > = 15 then |
10 | player.leaderstats.Kills.Value = player.leaderstats.Kills.Value - 15 |
11 | sword.Parent = backpack |
18 | plr:GetMouse().KeyDown:Connect( function (F) |
20 | game.StarterGui.ShopGui.Shop.Visible = false |
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.