#Gamepass
27 messages · Page 1 of 1 (latest)
this is the main script to buy the coil
local mps = game:GetService("MarketplaceService")
local gravitycoilId = script.GamepassID.Value
mps.PromptGamePassPurchaseFinished:Connect(function(plr,passId,purchased)
if purchased and passId == gravitycoilId then
script.GravityCoil:Clone().Parent = plr.Backpack
end
end)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
local ownsPass = mps:UserOwnsGamePassAsync(plr.UserId,gravitycoilId)
if ownsPass then
script.GravityCoil:Clone().Parent = plr.Backpack
end
end)
end)```
make it so the signal CharacterAdded adds it to their backpack
improved it but stuck on a new line
local GravityCoilGamepassID = 633104403
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GravityCoilGamepassID)
end)
if hasPass then
print(player.Name.." has the gamepass")
local clone = game:GetService("MarketplaceService"):GravityCoilGamepassID():GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
else
print(player.Name .. " does not have the gamepass")
end
end)
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess and purchasedPassId == GravityCoilGamepassID then
print(player.Name.. " has purchased the gamepass.")
local clone = game:GetService("MarketplaceService"):GravityCoilGamepassID():GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)```
everything works the way I want it to apart from the GetService in local clone = , not sure how to make it work trying to figure it out as I found this fix in another thread on how to fix the issue im having but I cant get it to work without something bugging out
GamePassService is only for legacy game passes, all new ones should just be done via MarketplaceService
I just edited it for some reason it pasted the wrong code I put the actual one I used in now
this part of this line is just a big no
yeah trying to find what I'm meant to use for it but I cant find what service is needed or if I can replace the whole getservice idea as a whole to make it work
that was just the last idea I had since substituted a few different things into that before it
the clone should just be
local clone = (Dotnav to gravityCoil (preferably in RS)):Clone()
sorry but how do I get it to do that? Its located in ServerScriptStorage under the scipt "GravityCoilScript" and the tool is called "GravityCoil"
** You are now Level 2! **
is the script the line will be going in that script?
I believe so,
the script is in the tool so if they get given the tool it should work from what I understand
local clone = script.GravityCoil:Clone()
Ok, thats fixed it so I now get the gamepass again but when you die/respawn it says you dont own it anymore
you need to handle the receipt before it counts I think
how would I do that? Should I try make it wait a second before it does anything or? Since I tried before with wait to make sure player and character were in the game before it checks anything as I heard that can cause problems but idk
or would I have to use something like this ? local playerProductKey = receiptInfo.PlayerId .. ':' .. receiptInfo.PurchaseId if PurchaseHistory:GetAsync( playerProductKey ) then return Enum.ProductPurchaseDecision.PurchaseGranted
ues beasically
yes
idk how others get it to work then without all this extra stuff , someone mentioned something about using starterpack but I think it would just give it to anyone who joined rather than those who bought it using that
on serversided scripts, yes