so I was trying to make a gravity coil gamepass with a gui aswell and made a script and I followed many tutorials but every single time it either says:
Or one time it just never gave the coil. I need help on how to make a script that works for that and I already have a gravity coil tool but a lot of the tutorials kept the scripts and tools in different places each time so im just not sure at this point but here is my current scripts:
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 86737822
local ToolName = "GravityCoil"
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID) then
script[ToolName]:Clone().Parent = player.Backpack
end
end)
end)
and these are the locations of the items I have
and another one
Please help when you can and if need where to put the things at because these youtube tutorials are all saying different things.
Add another script in ServerScriptService called GamepassManager and put this in:
--//Services
local MarketplaceService = game:GetService("MarketplaceService")
--//Tables
local passFunctions = {}
--//Functions
passFunctions[86737822] = function(player)
if not player.Character then
return
end
local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
newGravityCoil.Parent = player.Backpack
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess then
passFunctions[purchasedPassId](player)
end
end)
This isnβt very optimal though, because you should put your gears in ServerStorage. This will work though.
Ok well I followed it and it did work but now Iβm trying to make a speed coil one and I made a gamepass manager 2 which im pretty im not supposed to do and I think im supposed to make it inside the other gamepass manager but how would I go by doing that. Here is what i tried:
local passFunctions = {}
passFunctions[87111630] = function(player)
if not player.Character then
return
end
local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
newGravityCoil.Parent = player.Backpack
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess then
passFunctions[purchasedPassId](player)
end
end)
Itβs the same script only the id is the same and I already made the button and script like before but when I try buying the pass it works just doesnt give the item. Could you maybe help me there.
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local GravityCoil = script:FindFirstChildOfClass("Tool")
local GamepassId = 87111630
local function CheckIfUserHasGamepass(UserId : number, GamepassId : number) : boolean
local UserHasGamepass = false
local Works, HasGamepass = pcall(function()
return MarketPlaceService:UserOwnsGamePassAsync(UserId, GamepassId)
end)
if Works and HasGamepass == true then
UserHasGamepass = true
elseif not Works then
local Attempts = 0
repeat task.wait(1)
Works, HasGamepass = pcall(function()
return MarketPlaceService:UserOwnsGamePassAsync(UserId, GamepassId)
end)
Attempts += 1
until Works or Attempts >= 5
if Works and HasGamepass == true then
UserHasGamepass = true
end
end
return UserHasGamepass
end
Players.PlayerAdded:Connect(function(Player)
local UserHasGamepass = CheckIfUserHasGamepass(Player.UserId, GamepassId)
if UserHasGamepass then
local ClonedTool = GravityCoil:Clone()
local ClonedTool2 = GravityCoil:Clone()
ClonedTool.Parent = Player.Backpack
ClonedTool2.Parent = Player.StarterGear
end
end)
MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(Player, GamepassId, IsPurchased)
if IsPurchased and GamepassId == GamepassId then
local ClonedTool = GravityCoil:Clone()
local ClonedTool2 = GravityCoil:Clone()
ClonedTool.Parent = Player.Backpack
ClonedTool2.Parent = Player.StarterGear
end
end)
Where do I put this? I dont think I would replace the other script since this only has one ID or do I just put this one in the thing I said was gamepasschecker2 or something like that
You should not be making a new script for it, as there is no need.
Just change your GamepassManager script to this:
--//Services
local MarketplaceService = game:GetService("MarketplaceService")
--//Tables
local passFunctions = {}
--//Functions
passFunctions[86737822] = function(player)
if not player.Character then
return
end
local newGravityCoil = script.Parent.Script.GravityCoil:Clone()
newGravityCoil.Parent = player.Backpack
end
passFunctions[87111630] = function(player)
if not player.Character then
return
end
local newSpeedCoil = script.Parent.MySpeedCoil:Clone() --//Reference your speed coil
newSpeedCoil.Parent = player.Backpack
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess then
passFunctions[purchasedPassId](player)
end
end)
at this point I dont know anymore bruh it just doesnt work. I buy it and it brings me here and btw the speed coil is just called SpeedCoil and the gravity one called GravityCoil.
I said to reference your speed coil, if youβre speed coil wasnβt called MySpeedCoil then it wouldnβt have worked. You should check this out for some info:
I messed up what I meant to say is I changed the newSpeedCoil part to SpeedCoil didnβt work, ive tried making the MySpeedCoil to SpeedCoil still didnt work which i dont know how that would fix it when the gravity coil name was right and still didnt work so I just dont know