Загрузка данных


local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local event = Instance.new("RemoteEvent")
event.Name = "SetSpeedEvent"
event.Parent = ReplicatedStorage

local ALLOWED = { [16] = true, [23] = true, [30] = true }
local speeds = {}

event.OnServerEvent:Connect(function(player, speed)
	if typeof(speed) ~= "number" or not ALLOWED[speed] then return end
	speeds[player] = speed
	local char = player.Character
	local hum = char and char:FindFirstChildOfClass("Humanoid")
	if hum then hum.WalkSpeed = speed end
end)

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		hum.WalkSpeed = speeds[player] or 16
	end)
end)

Players.PlayerRemoving:Connect(function(player)
	speeds[player] = nil
end)