I created a cool EMF system inspired by Plasmaphobia!
- Give your feedback
- I have 5 months of experience
- I am French
local RunService = game:GetService("RunService")
local emfInformationModule = require(script.Parent.EmfInformation)
local player = game.Players.LocalPlayer
local character = player.Character
local humanoidRootPart = character.HumanoidRootPart
local rig = game.Workspace.AllMonsters.Deviant.HumanoidRootPart
local emfReader = script.Parent
local sounds = emfReader.Sounds
local emfNumbers = emfReader.EmfNumbers
local debounce = false
emfReader.Activated:Connect(function()
local connect
debounce = not debounce
connect = RunService.RenderStepped:Connect(function()
local emfMagnitudeRequire = {
[1] = emfInformationModule.new((rig.Position - humanoidRootPart.Position).Magnitude >= 50 or (rig.Position - humanoidRootPart.Position).Magnitude <= 50, Color3.new(0.588235, 1, 0.4)),
[2] = emfInformationModule.new((rig.Position - humanoidRootPart.Position).Magnitude <= 40, Color3.new(0.494118, 1, 0.309804)),
[3] = emfInformationModule.new((rig.Position - humanoidRootPart.Position).Magnitude <= 30, Color3.new(1, 0.886275, 0.321569)),
[4] = emfInformationModule.new((rig.Position - humanoidRootPart.Position).Magnitude <= 20, Color3.new(1, 0.607843, 0.290196)),
[5] = emfInformationModule.new((rig.Position - humanoidRootPart.Position).Magnitude <= 10, Color3.new(1, 0, 0.0156863)),
}
for index, information in emfMagnitudeRequire do
if debounce then
emfNumbers[index].Color = information.Color
if information.Magnitude then
emfNumbers[index].Material = Enum.Material.Neon
else
emfNumbers[index].Material = Enum.Material.Plastic
end
else
connect:Disconnect()
emfNumbers[index].Color = Color3.new(0, 0, 0)
emfNumbers[index].Material = Enum.Material.Metal
end
end
end)
end)
--local script
--Module
local emfInformation = {}
function emfInformation.new(magnitude, color: Color3)
local self = setmetatable({}, emfInformation)
self.Magnitude = magnitude
self.Color = color
return self
end
return emfInformation