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

How to increase leaderstat?

Asked by 4 years ago

I;m trying to code out a script that increase the leaderstat "headsize" whenever the u key is pressed and this is what I have so far:

x = 0

function KeyPress(input, gameProcessed)

  if input.KeyCode == Enum.KeyCode.U then

        x = x + 1   
  end
end

game:GetService("UserInputService").InputBegan:Connect(KeyPress)


game.Players.PlayerAdded:Connect(function(player)


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local headsize = Instance.new("IntValue")
    headsize.Name = "headsize"
    headsize.Value = x
    headsize.Parent = leaderstats

end)

The start works as it starts out with 0, but when I press the U key, nothing happens. I'm sure it's something simple that I'm just blind to, but if you can help me out thanks!

0
is this in one script or two scripts? 123nabilben123 499 — 4y
0
This is in one regular script inside of server script service if that helps Frostmaniz 4 — 4y

Answer this question