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

Can anyone tell me why my script isnt workking or give me a new script its on superspeed?

Asked by 3 years ago

local function CheckGamepass(player) local success, boughtGamepass = pcall(function() return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19990375) end)

if success and boughtGamepass then
    if player.Character and player.Character:FindFirstChild("Humanoid") then
        player.Character.Humanoid.Walkspeed = 75
    else
        player.CharacterAdded:Wait()
        player.Character:WaitForChild("Humanoid")
        player.Character.Humanoid.Walkspeed = 75
    end
end

end game.Players.PlayerAdded:Connect(function(player) CheckGamepass(player) player.CharacterAdded:Connect(function(character) CheckGamepass(game.Players:GetPlayerFromCharacter(character)) end) end)

can anyone tell me why?

1 answer

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

Capitalization for variables/properties matters!

You did not have the proper capitalization for the lines containing player.Character.Humanoid.WalkSpeed = 75:

-- This is correct:
player.Character.Humanoid.WalkSpeed = 75

-- You had this:
player.Character.Humanoid.Walkspeed = 75

This is the full script with the modifications made:

local function CheckGamepass(player) 
    local success, boughtGamepass = pcall(function() 
        return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 19990375) 
    end)


    if success and boughtGamepass then
        if player.Character and player.Character:FindFirstChild("Humanoid") then
            player.Character.Humanoid.WalkSpeed = 75
        else
            player.CharacterAdded:Wait()
            player.Character:WaitForChild("Humanoid")
            player.Character.Humanoid.WalkSpeed = 75
        end
    end
end 

game.Players.PlayerAdded:Connect(function(player) 
    CheckGamepass(player) 
    player.CharacterAdded:Connect(function(character) 
        --CheckGamepass(game.Players:GetPlayerFromCharacter(character)) 
        -- ^^ Not sure why you are getting the player from it's character...
        CheckGamepass(player)
    end) 
end)
0
Thanks! Ilands_master222 17 — 3y
Ad

Answer this question