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

How to make x2 Gamepass clicks?

Asked by 4 years ago

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

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. MrLonely1221 701 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago

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!

Log in to vote
0
Answered by 4 years ago
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

0
So i put this in gui where i button lovrotuk 7 — 4y
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 Barty200 85 — 4y

Answer this question