Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why cant I compare leaderstats with a local script?

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?

4 comments

0

Could not find a specific YT vid lol

0

Well are you really sure the leaderstats are a child of game?

0

No no entirely. The script for leaderstats was a model.

0

Here's what it says: Players.Username.PlayerGui.Shop.ShopFrame.LevelOne.LocalScript:1: attempt to index nil with 'leaderstats'

1 answer

✓ Accepted answer

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

1 comment

0

Is there a way to make this permenent?

This discussion is preserved as it was. New answers, comments, and votes are closed.