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

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

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

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

2 comments

0

Something went wrong.. Wall isn't being deleted even when I have 10 points.

0

did u change the "100" in abritishchap's script to something bigger or equal to 10??

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

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