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
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