Final fix (copy + paste):
local Players = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID = 1238025674
local debounce = {}
local playerOwnsPass = {}
local function checkOwnership(player)
local success, ownsPass = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID)
end)
if success then
playerOwnsPass[player] = ownsPass
else
playerOwnsPass[player] = false
end
end
local function applySpeedBoost(character, ownsPass)
local humanoid = character:WaitForChild("Humanoid")
if ownsPass then
humanoid.WalkSpeed = 32
else
humanoid.WalkSpeed = 16
end
end
Players.PlayerAdded:Connect(function(player)
checkOwnership(player)
player.CharacterAdded:Connect(function(character)
checkOwnership(player) -- <-- Re-check on spawn
applySpeedBoost(character, playerOwnsPass[player])
end)
end)
Players.PlayerRemoving:Connect(function(player)
playerOwnsPass[player] = nil
end)
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChild("Humanoid")
if not humanoid then return end
local player = Players:GetPlayerFromCharacter(character)
if not player then return end
if debounce[player] then return end
debounce[player] = true
checkOwnership(player)
if not playerOwnsPass[player] then
MarketplaceService:PromptGamePassPurchase(player, GamepassID)
end
task.delay(3, function()
debounce[player] = nil
end)
end)