If you would like to change everybody’s speed at the same time just do this:
local Players = game:GetService("Players")
local Speed = 16
for i, Player in pairs (Players:GetChildren()) do
local Character = Player.Character
Character.Humanoid.WalkSpeed = Speed
end
local WalkSpeed = -- Your value here
game.Players.PlayerAdded:Connect(function(player)
player.CharactedAdded:Connect(function(character)
character.Humanoid.WalkSpeed = WalkSpeed
end)
end)
local Walkspeed = 20 -- change it to whatever you want
for index, value in pairs(game.Players:GetChildren()) do
value.Character.Humanoid.WalkSpeed = Walkspeed
end
I’m trying all the scripts, non of them have worked for some reason. Not sure if this makes a difference but i’m changing the players walkspeed because I need it for a ‘Game Starting’ part and I don’t want the player to have the ability to move, but then eventually once the countdown has finished I then want the players to have the default walkspeed of 16.
--localscript
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key,gpe)
if gpe then return
if key.Keycode == Enum.Keycode.LeftShift then
-- fetch sprint remote in replicatedstorage
game.ReplicatedStorage.Sprint:FireServer("began")
end
end)
uis.InputEnded:Connect(function(key,gpe)
if gpe then return
if key.Keycode == Enum.Keycode.LeftShift then
-- fetch sprint remote in replicatedstorage
game.ReplicatedStorage.Sprint:FireServer("ended")
end
end)
--serverscript
local default = 20
local newSpeed = 25
local actions = {
["began"] = function(target)
local ch = target.Character
repeat wait() until ch ~= nil
local hum = ch:FindFirstChildOfClass("Humanoid")
hum.WalkSpeed = newSpeed
end,
["ended"] = function(target)
local ch = target.Character
repeat wait() until ch ~= nil
local hum = ch:FindFirstChildOfClass("Humanoid")
hum.WalkSpeed = default
end
}
game.ReplicatedStorage.Sprint.OnServerEvent:Connect(function(player,args)
actions[args](player)
end)