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

Gamepass script not giving walkspeed? [SOLVED]

Asked by
Agios 10
9 years ago

Cawlonee, I got the error: Workspace.Script:8: function arguments expected near ':'

The script is supposed to check if a player has the gamepass, and then change their walkspeed to 30. It's not changing the walkspeed.

local id = 216653360

game.Players.PlayerAdded:connect(function(newplayer)
local player = newplayer.Character
    local humanoid = player:WaitForChild("Humanoid")


    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 

    humanoid.Walkspeed = 30


    end
end)

Script I made that worked:

local id = 216653360

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then        
                character.Humanoid.WalkSpeed = 25
end 
    end)

end)

1 answer

Log in to vote
0
Answered by 9 years ago

Use the CharacterAdded event to give it on every respawn.

local id = 216653360

game.Players.PlayerAdded:connect(function(newplayer)
    newplayer.CharacterAdded:connect(function(character)
                local humanoid = character:WaitForChild("Humanoid")

        if game:GetService("GamePassService"):PlayerHasPass(newplayer, id) then 
          humanoid.WalkSpeed = 30 -- It's WalkSpeed, not Walkspeed
        end

    end)
end)

If you get anything in the output, tell me and Ill fix any syntax errors.

Ad

Answer this question