I am making a simulator game that gives strength everytime you click the screen with the tool in your hand
I am confused on how to make the gamepass that doubles the strength you gain from the tool
Notes - The remote is "Swing" and the leaderstats value is "Strength" and the tool that fires the remote is "Knife"
Scripts
Script that gives strength -
local replicatedStorage = game:GetService("ReplicatedStorage") local remoteData = game:GetService("ServerStorage"):WaitForChild("RemoteData") local cooldown = 0.5 replicatedStorage.Remotes.Swing.OnServerEvent:Connect(function(player) if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end local debounce = remoteData[player.Name].Debounce if not debounce.Value then print("got past the debounce if statement") debounce.Value = true player.leaderstats.Strength.Value = player.leaderstats.Strength.Value +15 wait(cooldown) debounce.Value = false end end)
I suggest searching on the internet on how to make this before actually asking it. There are guides on how to make it, but regardless, here you go.
We can use a service called MarketPlaceService. It's basically a service that is responsible for all the game monetization.
So first, create a gamepass under your game's name.
If you created it, get the Service by calling game:GetService()
local MPS = game:GetService("MarketPlaceService")
So now we got the Service, we can get the Player's userId by using player.UserId
in your script. Now let's perform a check if the player has the game pass.
(Make sure you already got the game pass ID, it can be found on the URL of the game pass)
local MPS = game:GetService("MarketPlaceService") replicatedStorage.Remotes.Swing.OnServerEvent:Connect(function(player) local ownGP pcall(function() -- I'm not sure if you need this, this is just how I was taught.. ownGP = MPS:UserOwnsGamePassAsync(player.UserId, 4) -- replace 4 with your game pass ID end) end)
Now we just checked if the player has the game pass. You can perform the checks on the Clients if you want; don't get scared, Exploiters can't access MarketPlaceService.
Now, we just do the usual thing, sanity checks and all that.
local MPS = game:GetService("MarketPlaceService") replicatedStorage.Remotes.Swing.OnServerEvent:Connect(function(player) local ownGP pcall(function() -- I'm not sure if you need this, this is just how I was taught.. ownGP = MPS:UserOwnsGamePassAsync(player.UserId, 4) -- replace 4 with your game pass ID end) if ownGP then -- If player has gamepass player.leaderstats.Strength.Value += (15*2) elseif not ownGP then -- If player doesn't have gamepass player.leaderstats.Strength.Value += 15 end end)