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

I am trying to make it so if somebody owns a certain gamepass that they get a 2x leaderstats boost?

Hi, i made a script that gives people a 2x boost if they own a certain gamepass I own the gamepass but i still only get + 1 leaderstats

Here is my code

local GamepassID = 10409558
local ClickAmount = 1

local debounce = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if debounce == false then
	debounce = true
	local PlayerClicks = player.leaderstats.Clicks
	PlayerClicks.Value = PlayerClicks.Value  + ClickAmount
	game.Players.PlayerAdded:Connect(function(player)
	
		if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamepassID) then
		PlayerClicks.Value = PlayerClicks + ClickAmount + 1
	end
end)


	wait(0.1)
	debounce = false
		end
end)
	







2 answers

✓ Accepted answer

You have two options here, the good way and the not good way, but works way.

The good way, move the PlayerAdded event outside of your MouseClick event and create a dictionary to cache whether they own the gamepass or not so your script won't have to yield every time it calls, UserOwnsGamePassAync. Then in your MouseClick event check if the player is a valid key in the dictionary and if they are, grant them their bonus.

The not good way, but works way is to remove the PlayerAdded event completely and inside the MouseClick event just check if they own the gamepass and grant them the bonus.

Also to double the amount of click's it will give you, you have to multiply the number by two.

PlayerClicks.Value = PlayerClicks.Value + (ClickAmount * 2)

1 comment

0

Works thanks

On line 13 try PlayerClicks.Value = PlayerClicks + ClickAmount + 2

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