This looks wrong and does not work

The script is simple!

It takes a players 100 and minus it by the players coins.

Why is it not working?

local Coins = game.Players.LocalPlayer.leaderstats.Coins
local Number = 100 - Coins

script.Parent.Text = "Sorry to do this action you need "...Number..." ."

Sometimes the LocalPlayer won’t entirely fully load as soon as you create the leaderstats, do make sure to call WaitForChild() for this certain instances so that you know when it’s properly defined:

local Coins = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Coins")
local Number = 100 - Coins.Value

script.Parent.Text = "Sorry to do this action you need "...Number..." ."

You also forgot to reference Coins.Value if this is a Value Object of some sort

2 Likes