0

# How do i make a x2 coins gamepass with this code?

So i have been wondering how to make a x2 coins gamepass and i need help, can i integrate a x2 coins gamepass with this code?

waittime = 13 -- Time Between each hit
amnt = 10 --how much you get for it
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
if (stats~=nil) then
local score = stats:findFirstChild("Coins")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end

script.Parent.Transparency = 1
script.Parent.CanCollide = false
script.Disabled = true
wait(waittime)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
script.Disabled = false

end
end

script.Parent.Touched:connect(onTouched)

0
Line 19 tho Ziffixture 6785 — 1mo
0
I would use a debounce instead of doing script.Disabled just in case it causes any problems. Other than that i think it would work fine. Also, I would make a base amount to give the player and then do an if statement to check if the player had the gamepass and if they do, amnt = amnt * 2, this could make your code easier to manage. YT_GamingDan 10 — 1mo
0
You must use a debounce. Disabling the Script will require second-hand reactivation. You can also just set up a Ternary using MarketplaceService's 'UserOwnsGamePassAsync' Boolean to bias amount or amount * 2. Ziffixture 6785 — 1mo
0
i have no idea how to script, my friend came up with this and he cant help me with the x2 coins game pass thing so i came here for some help coolperson21216 4 — 1mo

0
sO_Ov 210
1 month ago
Edited 1 month ago

I edited your code a little bit and this should work, all you need to do is get your gamepass id and change it to 'GamePassId'

local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamePassId = 15200883 -- your gamepass id here
local RespawnTime = 13
local Reward = 10
local Collected = false

function Touch(object)
if object.Parent:FindFirstChild("Humanoid") then
if Players:GetPlayerFromCharacter(object.Parent) then
local Player = Players:GetPlayerFromCharacter(object.Parent)
if leaderstats ~= nil and Coins ~= nil then
if not Collected then
Collected = true
if not MPS:UserOwnsGamePassAsync(Player.UserId, GamePassId) then
Coins.Value += Reward
else
Coins.Value += Reward *2
end
script.Parent.Transparency = 1
script.Parent.CanCollide = false
wait(RespawnTime)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
Collected = false
end
end
end
end
end

script.Parent.Touched:connect(Touch)

0
Thanks for the help,i have been struggling so much to make one! coolperson21216 4 — 1mo