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

How to make x2 Gamepass clicks?

Yo so i am new at scripting and i dont know where i need to put variables called clicknumber and clickcount. And i have in gui button with local script

local Player = game.Players.LocalPlayer
local PlayersClicks = Player:WaitForChild('leaderstats'):WaitForChild('Clicks')

script.Parent.MouseButton1Click:Connect(function()
	PlayersClicks.Value = PlayersClicks.Value + 1
end)

and this script

local clicknum = 1
local clickcount = 0 (unless you have datastore)
	 
 
script.Parent.MouseButton1Click:Connect(function()
	  clickcount = clickcount+clicknum
end)
	 
if [insert if you have gamepass here script] then
	    clicknum = 2
	end

I need to make gamepass for my game but i dont know how

1 comment

0

If you're trying to make a 2x click gamepass, and make it so that their number of clicks is clickCount*2, you can do just that.

3 answers

✓ Accepted answer

You cant change the clicks on the client, you gotta change it on the server so you can use a remote event and send data to it. Then from there you can use a bool value that is in starter gui just so it is entierally local.

The way you're going to want to go about doing it, is send the click to the server. Then on the server after you register it, you're going to multiply it by 2 if they have the gamepass.

So instead of your code you would do something like

local clicknum = 1
local clickcount = 0 (unless you have datastore)
 
 
script.Parent.MouseButton1Click:Connect(function()
      clickcount = clickcount+clicknum
      game:GetService("ReplicatedStorage").ClickRemote:FireServer(clickcount);
end)

Then on the server register these and multiply it by 2

game:GetService("ReplicatedStorage").ClickRemote.OnServerEvent:Connect(function(player, clickCount)
  if [player.OwnsGamepass] then
    clickCount = clickCount * 2;
  end;

  player.Stats.Clicks = player.Stats.Clicks + clickCount;
end);

Hope this helps!

local id = gamepass id
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        clicknum = 2
    end
end)

wait(5)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
            clicknum = 2
        end
    end)
end)

Put this at the very begining of your code, the top function is called when the player buys a gamepass in the game and the bottom one is called if the player has the gamepass

2 comments

0

So i put this in gui where i button

0

You will have to use remote events for this so you can either do in the gui button and send the clicknum value or you can do it in the server and have it multiply the value it recieved

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