local ReplicatedStorage = game:GetService(“ReplicatedStorage”) local Players =…
- User
local ReplicatedStorage = game:GetService(“ReplicatedStorage”) local Players = game:GetService(“Players”)
local player = script.Parent – Ссылка на игрока
– Создаём событие для передачи информации о активации способностей local OmniManAbilityEvent = Instance.new(“RemoteEvent”) OmniManAbilityEvent.Name = “OMNIMAN_Ability” OmniManAbilityEvent.Parent = ReplicatedStorage
– Переменные для управления способностями local ability1Cooldown = 10 local ability1Duration = 30 local ability1Active = false local ability2Active = false local ability4Cooldown = 5 local ability4Active = false local ability4HealingRate = 200
local ability1CooldownTimer = ability1Cooldown local ability4CooldownTimer = ability4Cooldown
– Максимальное значение маны local maxMana = 1490 local currentMana = maxMana
– Проверка хватает ли маны для использования способности local function hasEnoughMana(requiredMana) return currentMana >= requiredMana end
– Уменьшение текущей маны local function decreaseMana(amount) currentMana = currentMana - amount if currentMana < 0 then currentMana = 0 end end
– Восстановление маны local function regenerateMana() while wait(1) do if currentMana < maxMana then currentMana = currentMana + 10 – Изменить значения для скорости восстановления маны if currentMana > maxMana then currentMana = maxMana end end end end
– Передача сигнала о состояниях способностей local function sendAbilityStatus() OmniManAbilityEvent:FireAllClients(ability1Active, ability2Active, ability4Active) end
– Способность 1: Сверхчеловеческая сила local function useAbility1() if not hasEnoughMana(100) or ability1Active then return end
ability1Active = true decreaseMana(100) sendAbilityStatus()
wait(ability1Duration) ability1Active = false ability1CooldownTimer = ability1Cooldown sendAbilityStatus() end
– Способность 2: Выносливость и устойчивость local function toggleAbility2() if not hasEnoughMana(1) then return end
ability2Active = not ability2Active sendAbilityStatus()
decreaseMana(1) end
– Способность 3: Неуязвимость local function useAbility3() if not hasEnoughMana(200) then return end
decreaseMana(200)
– Реализовать действия способности end
– Способность 4: Усиленный лечебный фактор local function useAbility4() if not hasEnoughMana(75) or ability4Active then return end
ability4Active = true decreaseMana(75) sendAbilityStatus()
local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild(“Humanoid”)
local function regenerateHealth() while ability4Active do humanoid.Health = humanoid.Health + ability4HealingRate wait(1) end end
coroutine.wrap(regenerateHealth)()
wait(ability4Cooldown) ability4Active = false ability4CooldownTimer = ability4Cooldown sendAbilityStatus() end
- Assistant
To make the script send the OMNIMAN_Ability event to the ReplicatedStorage, you can modify the relevant parts of the code as follows:
lualocal OmniManAbilityEvent = game.ReplicatedStorage:WaitForChild("OMNIMAN_Ability") -- ... local function sendAbilityStatus() OmniManAbilityEvent:FireServer(ability1Active, ability2Active, ability4Active) end -- ... local function useAbility1() -- ... sendAbilityStatus() end -- ... local function toggleAbility2() -- ... sendAbilityStatus() end -- ... local function useAbility4() -- ... sendAbilityStatus() end -- ... local function useAbility5() -- ... sendAbilityStatus() endIn this modified script, the
OmniManAbilityEventvariable is now assigned the reference to the "OMNIMAN_Ability" RemoteEvent in the ReplicatedStorage. The function now uses to send the ability status to the server.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.