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

How to change the walkspeed depending on team?

Asked by 10 years ago

I have tried but no luck. Help please?

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

I'd do something like this-

local TeamSpeeds = {
    -- ["team color"] = walkspeed
    ["White"] = 16,
    ["Really black"] = 32
}

Game:GetService("Players").PlayerAdded:connect(function(plr) -- when a player joins
    plr.CharacterAdded:connect(function(char) -- when that player respawns
        if TeamSpeeds[plr.TeamColor.Name] then -- if their team is found in TeamSpeeds
            char:WaitForChild("Humanoid").WalkSpeed = TeamSpeeds[plr.TeamColor.Name] -- set their walk speed to what is set in the table TeamSpeeds
        end
    end)
end)
Ad
Log in to vote
-1
Answered by 10 years ago

Where is my +1.

--TochiWasHere

function GetSpeedByTeam(color,speed)
    for i, v in pairs(game.Players:GetPlayers()) do
        tmclr = tostring(v.TeamColor)
        if tmclr == color then 
            v.Character.Humanoid.WalkSpeed = speed
        else
            wait()
        end
    end
end

GetSpeedByTeam("White",100)
GetSpeedByTeam("Black",500)

--add more here if you have more teams and make sure you spell the teamcolor CORRECTLY.

Answer this question