Try this:
local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
mps:PromptGamePassPurchase(game.Players.LocalPlayer, script.Parent:WaitForChild("GamepassID").Value)
end)
Try this:
local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Click:Connect(function()
mps:PromptGamePassPurchase(game.Players.LocalPlayer, script.Parent:WaitForChild("GamepassID").Value)
end)
Can you check name of instance?
Where do i check that i am quiet new.
do you have a gamepassID? if yes could you send it to us?
Check GamepassID name like if it is the same.
Here you go thats my gamepass id 255612370
Can you show us a screenshot of the Explorer window?
Thanks but do you know how to make the gamepass item work so when i buy it it gives me the item
Are you sure it’s the original climb 1000 stairs?
Umm ur right i should change it
I made new Topic You can chek it out if you want to.
I dont see ur messages just write on my new TOPIC
Add this Tool to ReplicatedStorage
Then make Script in ServerScriptService
And add this code into this script:
local rs = game:GetService("ReplicatedStorage")
local mps = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local Tool = rs:WaitForChild("PutHereToolName")
local gamePassId = 255612370
local function AddTool(player)
if mps:UserOwnsGamePassAsync(player.UserId,gamePassId) then
local Clone = tool:Clone()
Clone.Parent = player:WaitForChild("Backpack")
end
end
plrs.PlayerAdded:Connect(AddTool)
mps.PromptGamePassPurchaseFinished:Connect(AddTool)
Check if player has the game pass using MarketplaceService:UserOwnsGamePassAsync()
and detecting when the player bought the game pass in-game using MarketplaceService.PromptGamePassPurchaseFinished
.
Then, give the player the rainbow carpet using InsertService:LoadAsset()
and gear id of rainbow carpet which is 225921000
.
-- place this script in ServierScriptService, must be a normal script
local Players = game:GetService("Players")
local Debris = game:GetService("Debris") -- used for deleting instances
local MarketplaceService = game:GetService("MarketplaceService")
local InsertService = game:GetService("InsertService")
local gamePassId = 255612370 -- rainbow carpet game pass
local gearId = 225921000 -- rainbow carpet gear
local function rewardPlayer(player: Player)
local gearModel = InsertService:LoadAsset(gearId)
local gear = gearModel:FindFirstChildWhichIsA("BackpackItem") -- gets the tool or hopperbin in gearModel
gear:Clone().Parent = player:WaitForChild("Backpack")
gear.Parent = player:WaitForChild("StarterGear")
Debris:AddItem(gearModel, task.wait()) -- deletes gearModel
end
local function playerJoined(player: Player)
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
rewardPlayer(player)
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, id, success)
if id == gamePassId and success == true then
rewardPlayer(player)
end
end)
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(playerJoined, player)
end
Players.PlayerAdded:Connect(playerJoined)
post this on my other topic
so i can check as solution
To check if player have gamepass:
local user_have_gamepass = game:GetService('MarketplaceService'):UserOwnsGamePassAsync(Player.UserId, Gamepass_ID) -- Cheking if player have item.
if user_have_gamepass then
-- Give item
end
-- ^ This part of code can be used for client-side or server-side scripts. ^
-- Event that fired only when player prompted purchase:
game:GetService('MarketplaceService').PromptGamePassPurchaseFinished:Connect(function(Player, Gamepass_ID, Was_Purchased)
if Player and Gamepass_ID == *Id of gamepass* and Was_Purchased then
-- Give item to player.
end
end)
-- ^ This part of code can be used only for server-side scripts. ^
Oh, I guess I’m mistaken. When I learned to script it was always do it on the server for extra protection or something… idrk, anyway if it works on the client then that’s great!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.