Players have to rejoin to gain the gamepass benefits i want them to gain benefits immediatly

i want it to check if they own the gamepass immediatly not just after rejoining the script is:
local Players = game:GetService(“Players”)
local MarketPlaceService = game:GetService(“MarketplaceService”)

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild(“Humanoid”)
local GamepassID = 268694445
local Multiplier = 1.5
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then
Humanoid.WalkSpeed = Humanoid.WalkSpeed * Multiplier

	end
end)

end)

1 Like

In your current script, does resetting do the job?

no it doesnt seem to only upon rejoining

i tried this, im not quite sure how characteradded events work but it didnt seem to change the script


MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)

end)

this will fire when the player has bought a gamepass

1 Like

where exactly would i put this would i use it in
local Players = game:GetService(“Players”)
local MarketPlaceService = game:GetService(“MarketplaceService”)

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild(“Humanoid”)
local GamepassID = 268694445
local Multiplier = 20
if MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
then

	Humanoid.WalkSpeed = Humanoid.WalkSpeed * Multiplier

	end
end)

end)
or would i have to use a diffrent script

I think you can put this anywhere in the script outside

ok i have done it now for anyone wanting the full script it is:
local Players = game:GetService(“Players”)
local MarketplaceService = game:GetService(“MarketplaceService”)

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild(“Humanoid”)
local GamepassID = 268694445
local Multiplier = 20

    local function HandleGamePassPurchase(player, gamePassId, wasPurchased)
        if gamePassId == GamepassID and wasPurchased then
            Humanoid.WalkSpeed = Humanoid.WalkSpeed * Multiplier
        end
    end

    MarketplaceService.PromptGamePassPurchaseFinished:Connect(HandleGamePassPurchase)
end)

end)
thanks alot

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.