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

Why cant I compare leaderstats with a local script?

Asked by 3 years ago
Edited 3 years ago

I am trying to make a button that you can buy something but only if you have a certain amount of "Deaths"

here's my script:

 if game.leaderstats.Deaths.Value == 1 then 
    game.Workspace.Parent.StarterPlayer.CharacterWalkSpeed = 70
 end

Can you help me?

0
Could not find a specific YT vid lol kickoff127 103 — 3y
0
Well are you really sure the `leaderstats` are a child of `game`? Spjureeedd 385 — 3y
0
No no entirely. The script for leaderstats was a model. kickoff127 103 — 3y
0
Here's what it says: Players.Username.PlayerGui.Shop.ShopFrame.LevelOne.LocalScript:1: attempt to index nil with 'leaderstats' kickoff127 103 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

leaderstats is not a valid member of game, if you have output open, you will see this error the fix for this is to check the player leaderstats if you even have one by doing this (im assuming you already got a player variable for the player trying to buy something)

if player.leaderstats.Deaths.Value == 1 then
--also, doing .Parent on workspace brings you back to game and my guess from your script is, you want to give the player 70 walkspeed, you do it like this
    player.Character.Humanoid.WalkSpeed = 70
end
0
Is there a way to make this permenent? kickoff127 103 — 1y
Ad

Answer this question