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

Why am I getting 0 points when I start?

I have a script that's supposed to give you 500 points when you join if you have a gamepass, and 1000 points when you join if you have another or both.

game.Players.PlayerAdded:connect(function(plr)
    local p = Instance.new('IntValue',plr)
    p.Name = 'Points'
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,252253525 --[[ 500 points ]]) then
		if not game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,252255271) then
			p.Value = 500
		end
	elseif game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,252255271 --[[ 1000 points ]]) then
		p.Value = 1000
	else
		p.Value = 0
	end
end)

The thing is I get 0 points when I join and I have both. There are no errors either.

I'm also new to gamepasses and MarketplaceService

1 answer

✓ Accepted answer

Code Fixes

You have the right idea but how you're doing this is probably messing it up. Try just checking if they have the 1000, if they don't then check if they have the 500, if not then give them 0



Efficiency Fixes

  • Make a variable for defining MarketplaceService

If you do this, you won't have to type out game:GetService('MarketplaceService') so many times

  • Make a table for your gamepasses

This is just for organization

  • Consider using standard roblox leaderboard setup

If you're expecting a leaderboard setup, you need to have a 'leaderstats' value in the player, and any stats as direct descendants if that value. This is completely up to you though.



Code

local ms = game:GetService('MarketplaceService')
local passes = {
	Thousand = 252255271,
	Hundred = 252253525
}

game.Players.PlayerAdded:connect(function(plr)
	local p = Instance.new('IntValue',plr)
	p.Name = 'Points'
	if ms:PlayerOwnsAsset(plr,passes.Thousand) then --1000
		p.Value = 1000
	elseif ms:PlayerOwnsAsset(plr,passes.Hundred) --500
		p.Value = 500
	else --0
		p.Value = 0
	end
end)

2 comments

0

Didn't think of a leaderboard setup but I'll try... http://gyazo.com/ec4a6378999fdb5372474ff2d5cf98fa is what i want the game to look like.

0

If you want something like that then there's no need for a leaderboard setup(: That was just in case you were meaning for this to be on a roblox leaderboard,

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