Can someone please help me make a local script that increases a player's max Hp after they buy a game pass?
I have tried for a few hours to make this local script but it won't work. this is what I have so far... local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players")
local gamePassID = 6609505 -- Change this to your game pass ID
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.CharacterAdded:Connect(function(character)
local humanoid = character:FindFirstChild("Humanoid")
humanoid.MaxHealth = 500
end)
end
end
-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function Players.PlayerAdded:Connect(onPlayerAdded)
Can someone please help me???

3 comments
I can help you. Add me on discord ToxicScript TV #6171
The reason for your error is because you need something called a "Remote Event". Running something client side only changes it for the user's device
Or change local script to server script. You don't need it to be in local.