Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Kills is not a part of leaderstats glitch?

Asked by 2 years ago

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:

01local Players = game.Players
02 
03local Template = Instance.new("BoolValue")
04Template.Name = "leaderstats"
05 
06Instance.new("IntValue", Template).Name = "Kills"
07Instance.new("IntValue", Template).Name = "Deaths"
08 
09Players.PlayerAdded:Connect(function(player)
10    wait(1)
11    local Stats = Template:Clone()
12    Stats.Parent = player
13    local Deaths = Stats.Deaths
14    player.CharacterAdded:Connect(function(Character)
15        Deaths.Value = Deaths.Value + 1
View all 32 lines...

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)

01player = game.Players.LocalPlayer
02backpack = player.Backpack
03local plr = game.Players.LocalPlayer
04 
05plr:GetMouse().KeyDown:Connect(function(K)
06    if K == "e" then
07        local sword = game.Lighting.Tools.ClassicSword:Clone() ---- change "ClassicSword" to the name of your tool
08 
09        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
10            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
11            sword.Parent = backpack
12        end
13    end
14end)
15 
View all 22 lines...

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.

1 answer

Log in to vote
0
Answered by 2 years ago

The issue with this is I had 2 leaderstats by accident, and they were clashing.

0
Why dont you use User Input Service instead of :GetMouse() Hi_People1133 218 — 2y
0
I have no clue what that is kickoff127 103 — 2y
Ad

Answer this question