Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local module = {}
- module.spinEnabled = true -- можно менять из других скриптов
- local function spinCharacter(character)
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local spinConnection = nil
- -- Функция для обновления состояния вращения
- local function updateSpin()
- -- Если вращение активно и персонаж жив
- if module.spinEnabled and humanoidRootPart and humanoidRootPart.Parent then
- -- Удаляем старое соединение (если есть)
- if spinConnection then
- spinConnection:Disconnect()
- end
- -- Запускаем новое вращение
- spinConnection = game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
- humanoidRootPart.Orientation += Vector3.new(0, 300 * deltaTime, 0) -- 300° в секунду
- end)
- else
- -- Если вращение выключено, останавливаем
- if spinConnection then
- spinConnection:Disconnect()
- spinConnection = nil
- end
- end
- end
- -- Следим за изменениями spinEnabled
- local enabledChangedConnection
- enabledChangedConnection = game:GetService("RunService").Heartbeat:Connect(function()
- updateSpin()
- end)
- -- Останавливаем всё при смерти персонажа
- character:WaitForChild("Humanoid").Died:Connect(function()
- if spinConnection then spinConnection:Disconnect() end
- if enabledChangedConnection then enabledChangedConnection:Disconnect() end
- end)
- end
- -- Подключение игроков
- game.Players.PlayerAdded:Connect(function(player)
- player.CharacterAdded:Connect(spinCharacter)
- end)
- -- Для уже существующих игроков
- for _, player in ipairs(game.Players:GetPlayers()) do
- if player.Character then
- task.spawn(spinCharacter, player.Character)
- end
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement