For some reason, this doesnt last after they die? Wouldn't the player added just repeat the script? Im confused, any way to make it work even after they die/respawn?
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamePassID = 836664
local function onPlayerAdded(player)
local hasPass = false
-- Check if the player already owns the game pass
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)
-- If there's an error, issue a warning and exit the function
if not success then
warn("Error while checking if player has pass: " .. tostring(message))
return
end
if hasPass == true then
print(player.Name .. " owns the game pass with ID " .. gamePassID)
player.Character.Humanoid.WalkSpeed = 30
end
end
game:GetService('Players').PlayerAdded:Connect(onPlayerAdded)

2 comments
If there is any problem I know off bat, I believe the "UserId" has to be "userId"... correct me if I am wrong.
Also, the PlayerAdded only works when they first join. This doesn't continue when a player dies.