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

Gamepass Walkspeed giver, refusing to work?

Asked by 6 years ago

Not sure, any help? I'm using the new gamepass call functions..

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

local gamePassID = 836664  

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.Humanoid.WalkSpeed = 30
    end
end

1 answer

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

Add this at the end of your code:

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

And on your line 22, make player.Humanoid.WalkSpeed = 30 to player.Character.Humanoid.WalkSpeed = 30

0
for some wierd reason, while testing it, its still not working? no errors though? GenericTM 2 — 6y
0
disregard, fixed it, thank you GenericTM 2 — 6y
Ad

Answer this question