local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local imageButton = script.Parent
local GAMEPASS_ID = 3430039237
local MAX_STEPS = 10
local stepsUsed = 0
local hasGamepass = false
local canWalk = false
-- Wait for LocalPlayer to be available
if not LocalPlayer then
Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
LocalPlayer = Players.LocalPlayer
end
-- Function to prompt gamepass purchase
local function promptGamepass()
if LocalPlayer then
local success, err = pcall(function()
MarketplaceService:PromptGamePassPurchase(LocalPlayer, 3430039237)
end)
if not success then
warn("Failed to prompt gamepass purchase: " .. tostring(err))
-- Optionally show UI to indicate error
end
else
warn("LocalPlayer not available for gamepass purchase prompt.")
-- Optionally show UI to indicate error
end
end
-- Listen for purchase finished
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedGamePassId, wasPurchased)
if player == LocalPlayer and purchasedGamePassId == 3430039237 and wasPurchased then
hasGamepass = true
canWalk = true
stepsUsed = 0
-- Optionally show UI to indicate steps available
end
end)
-- Check if player already owns gamepass
local function checkGamepass()
if LocalPlayer then
local success, owns = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(LocalPlayer.UserId, 3430039237)
end)
if success and owns then
hasGamepass = true
canWalk = true
stepsUsed = 0
end
end
end
checkGamepass()
imageButton.MouseButton1Click:Connect(function()
if not hasGamepass then
promptGamepass()
else
canWalk = true
stepsUsed = 0
-- Optionally show UI to indicate steps available
end
end)
-- Track steps
local function onStepped()
if canWalk and LocalPlayer and LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
local humanoid = LocalPlayer.Character:FindFirstChild("Humanoid")
if humanoid and humanoid.MoveDirection.Magnitude > 0 then
stepsUsed = stepsUsed + 1
if stepsUsed >= MAX_STEPS then
canWalk = false
-- Fire remote to server to freeze player
ReplicatedStorage:WaitForChild("FreezePlayerAfterSteps"):FireServer()
end
end
end
end
RunService.Stepped:Connect(onStepped)```
#Gamepass
1 messages · Page 1 of 1 (latest)
I heard that marketplaceservice doesnt really work in studio do you get the popup to pay for it and wehn you pay for it you get this error or do you get it wehn you step on it