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

How can I change the walkspeed of the players as a round is about to start?

Asked by 4 years ago

I have added this code in several different locations throughout the script. Nothing is working. I really don't have any idea how to fix this, and I need help. Thank you. The attempt to change the walk speed is found at the top and bottom of the script.

character.WalkSpeed = 0

local plrs = {}

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs,player) --Add each player into the plrs table.
    end
end

-- Teleport players to the map

local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")

if not SpawnPoints then
    print("Error: Spawnpoints not found!")
end

local AvailableSpawnPoints = SpawnPoints:GetChildren()

for i, player in pairs(plrs) do
    if player then
        character = player.Character

        if character then
            -- Teleport them

            character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,20,0)
            table.remove(AvailableSpawnPoints,1)



            --Give them their weapon.

            local equipped = game.ServerStorage.PlayerData[player.Name].Equipped

            if equipped.Value ~= "" then
                local weapon = game.ServerStorage.Items[equipped.Value]:Clone()
                weapon.Parent = player.Backpack
            else
                local Sword = ServerStorage.Sword:Clone()
                Sword.Parent = player.Backpack
            end

            local GameTag = Instance.new("BoolValue")
            GameTag.Name = "GameTag"
            GameTag.Parent = player.Character

        else
            --There is no character
            if not player then
                table.remove(plrs,i)
            end
        end
    end
end


--Load skybox

Status.Value = "Get ready!"
wait(3)
Status.Value = "3"
wait(1)
Status.Value = "2"
wait(1)
Status.Value = "1"
wait(1)
Status.Value = "Go!"

character.WalkSpeed = 24
0
Have you tried changing the walkspeed of the players in the "plrs" table you made? SamTheEnthusiast 70 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
-- server
for i, v in pairs(game.Players:GetPlayers()) do
    if v and v.Character and v.Character:FindFirstChild("Humanoid") then
        v.Character.Humanoid.WalkSpeed = 24
    end
end
Ad

Answer this question