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

Walkspeed Gamepass dont work or stay permanent?

added the characteradded function to make it permanent, but it still refuses to work?

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 836664  

game.Players.PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character) --this will fire every time a player's character spawns
        character:WaitForChild("Humanoid")
        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)
end)

game:GetService('Players').PlayerAdded:Connect(onPlayerAdded)

2 comments

0

Erm, not sure if it'll help but it seems that you have indented your 'CharacterAdded' function too much.

0

Forgot local player soo

1 answer

Make sure the GamePass / Developer Product is purchased and then goto your script and make sure when the player has the gamepass then you will make the walkspeed higher, Example

WalkSpeed (GamePass): game.Players.LocalPlayer.Humanoid.WalkSpeed = 20 [Change to walkspeed amount]

WalkSpeed (Developer Product): game.Players.LocalPlayer.Humanoid.WalkSpeed = game.Players.LocalPlayer.Humanoid.WalkSpeed + 5 [Every time its purchased it will get higher]

Whole Script For gamepass

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local gamePassID = 0000000  -- 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)
		game.Players.LocalPlayer.Humanoid.WalkSpeed = 20 
    end
end
 
-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
Players.PlayerAdded:Connect(onPlayerAdded)

If this doesn't Work Check the Roblox wiki! Theres better info there.

http://robloxdev.com/

1 comment

0

i want it to be perm tho, this only works when they join, not when they die.

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