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

Whats wrong with my group walkspeed script?

Asked by
duckyo01 120
8 years ago

I tried making it so if they are in my group they get a 5% more walkspeed. It wont work for some reason here it is.

local groupId = 2578189
local speed = 17


local function newPlayer( player )
    if player:IsInGroup(groupId) then -- if player isingroup
        player.CharacterAdded:connect(function( character ) -- wait for character
            local humanoid = character.Humanoid -- character's humanoid

            if humanoid then -- if humanoid exisits
            humanoid.WalkSpeed = speed -- set speed
            end;
        end);
    end;
end

game.Players.PlayerAdded:connect( newPlayer ) -- connect event to callback func
table.foreach(game.Players:GetPlayer(), function(i, v)
  newPlayer( v )
end)

Please tell me where I went wrong or what the script is supposed to be. Thanks in advance

1 answer

Log in to vote
1
Answered by 8 years ago

I just don't know what went wrong, I'll rewrite the code and see if it works. If it works then I don't know what happened.

local groupId = 2578189
local speed = 16.8 --WalkSpeeds can have decimals.

game:GetService("Players").PlayerAdded:connect(function(plyr)
    plyr.CharacterAdded:connect(function(char)
        if plyr:IsInGroup(groupId) then
            local h = char:WaitForChild("Humanoid")
            h.WalkSpeed = speed
        end
    end)
end)

Hope it helps!

Ad

Answer this question