Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Walkspeed Gamepass dont work or stay permanent?

Asked by 5 years ago

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)
0
Erm, not sure if it'll help but it seems that you have indented your 'CharacterAdded' function too much. NoirPhoenix 148 — 5y
0
Forgot local player soo MarkHasReset 77 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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/

0
i want it to be perm tho, this only works when they join, not when they die. GenericTM 2 — 5y
Ad

Answer this question