I want to make a gamepass that gives a 2x gaining boost to my stats. I’ve tried various ways and still couldn’t solve it. Any help is appreciated.
My gamepass script
local marketservice = game.MarketplaceService
local players = game.Players
local eter = require(game.ReplicatedStorage.EternityNum)
local gamepassid = 844233336
local function GivePerk(player)
local cash = eter.convert(player.Leaderstats.Cash.Value)
local multi = eter.convert(player.Leaderstats.Multiplier.Value)
local reb = eter.convert(player.Leaderstats.Rebirths.Value)
cash = eter.mul(eter.convert(player.Leaderstats.Cash.Value), 2)
multi = eter.mul(eter.convert(player.Leaderstats.Multiplier.Value), 2)
reb = eter.mul(eter.convert(player.Leaderstats.Rebirths.Value), 2)
player.Leaderstats.Cash.Value = eter.toScientific(cash)
player.Leaderstats.Multiplier.Value = eter.toScientific(multi)
player.Leaderstats.Rebirths.Value = eter.toScientific(reb)
end
local function PlayerAdded(player)
local haspass = false
local success, errormsg = pcall(function()
haspass = marketservice:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if not success then
error(errormsg)
return
end
if haspass then
GivePerk(player)
end
end
players.PlayerAdded:Connect(PlayerAdded)
I changed the haspass from a bool to a table to manage multiple players. Anyways I hope it works! ;D
local marketservice = game:GetService("MarketplaceService")
local players = game:GetService("Players")
local eter = require(game.ReplicatedStorage.EternityNum)
local haspass = {}
local gamepassid = 844233336
local function GivePerk(player)
local cash = eter.convert(player.Leaderstats.Cash.Value)
local multi = eter.convert(player.Leaderstats.Multiplier.Value)
local reb = eter.convert(player.Leaderstats.Rebirths.Value)
cash = eter.mul(eter.convert(player.Leaderstats.Cash.Value), 2)
multi = eter.mul(eter.convert(player.Leaderstats.Multiplier.Value), 2)
reb = eter.mul(eter.convert(player.Leaderstats.Rebirths.Value), 2)
player.Leaderstats.Cash.Value = eter.toScientific(cash)
player.Leaderstats.Multiplier.Value = eter.toScientific(multi)
player.Leaderstats.Rebirths.Value = eter.toScientific(reb)
end
local function PlayerAdded(player)
local success, errormsg = pcall(function()
haspass[player] = marketservice:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if not success then
error(errormsg)
return
end
if haspass[player] then
GivePerk(player)
end
end
players.PlayerAdded:Connect(PlayerAdded)
The results are the same as the old code. What I’ve meant by 2x stats is 2x stats gaining. My bad for not saying it well. Thanks for trying to help me.