Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

For some reason in studio whenever you buy the game pass it wont change the speed?

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if game.MarketplaceService:PlayerOwnsAsset(player,10763132) then
			character.Humanoid.WalkSpeed = 32
		end
	end)
end)

I inserted a local script inside of the Text button and the script was this

script.Parent.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,10763132)
end)

please help me

1 answer

Tiny error mistake you made.

You were supposed to use UserOwnsGamePassAsync instead of PlayerOwnsAsset since that is deprecated and we are not checking an asset.

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/UserOwnsGamePassAsync

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,10763132) then
            character.Humanoid.WalkSpeed = 32
        end
    end)
end)

Edit: Also use player.UserId so if the player changes username you can still track if they own the gamepass. Also use game:GetService() for MarketPlace

Edit2: Ah I see what you need.

game.Players.PlayerAdded:Connect(
    function(player)
        player.CharacterAdded:Connect(
            function(character)
                local CheckIfUserOwnsGamepassThread =
                    coroutine.create( --Making a new thread so you can edit the rest of the code peacefully without having to worry about everything after this
                     
                    function()
                        while wait(1) do --Just for less pressure
                            if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 10763132) then
                                character.Humanoid.WalkSpeed = 32
                            end
                        end
                    end
                )
                coroutine.resume(CheckIfUserOwnsGamepassThread)
            end
        )
    end
)

So I have made a coroutine so you can continue after in case you wanted to add to the player added event. I have also added a while loop checking if the user owns the gamepass and it will change their Humanoid's WalkSpeed to 32.

3 comments

0

how can a human being be so damn fast

0

2x Speed

0

You need to use pcall instead.

This discussion is preserved as it was. New answers, comments, and votes are closed.