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

How to check player's leaderstats named "Points"?

Asked by 4 years ago

So I'm making a clicker game, and I want to do ontouched event to unlock new shop, but I don't know how to check player's current leaderstats :/ ... I want to destroy the wall if success and subtract player's points. (50B)

2 answers

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
4 years ago

I assume you have already defined the player you are checking the Points for via GetPlayerFromCharacter().

After defining player, what you'd do is then use if statements to check if the Player has the correct amount of points.

local pLeaderstats = Player:FindFirstChild('leaderstats')
if pLeaderstats then -- check if player has leaderstats yet
    local points = pLeaderstats:WaitForChild('Points') -- wait for points to be in leaderstats
    if points.Value >= 100 then -- check if they have x amount of points or more
        -- more code here
    end
end
0
Something went wrong.. Wall isn't being deleted even when I have 10 points. KoxiThePlayerPL 37 — 4y
0
did u change the "100" in abritishchap's script to something bigger or equal to 10?? Lunaify 66 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Credits to ABritishChop:

Workspace = game:GetService("Workspace")
local pLeaderstats = Player:FindFirstChild('leaderstats')
if pLeaderstats then -- check if player has leaderstats yet
    local points = pLeaderstats:WaitForChild('Points') -- wait for points to be in leaderstats
    if points.Value >= 100 then -- check if they have x amount of points or more
        -- more code here
    Workspace:WaitForChild("Wall").CanCollide = false
    Workspace:WaitForChild("Wall").Transparency = 1
    end
end

change the path of "Wall" to the part of your wall

Answer this question