i don't want to come up with something.
btw print statements are for debugunknown
lua
a year ago
3.2 kB
13
Indexable
local pumpOnline = false
local onlineAmount = 0
local damageAmount = 0
local isSet = false
if script.Parent:WaitForChild("1", 5) == nil then error("bruh") end
local lights = { script.Parent["1"], script.Parent["2"], script.Parent["3"] }
local fadeCurrentTime = 0
local prevFadeState = nil
-- configuration
local timeToStart = 30
local timeToStop = 30
local soundMaxPitch = 1
local faultColourBlink = Color3.new(1, 1, 0)
local faultColourBlinkOff = Color3.new(0, 0, 0)
local faultBlinkTime = 1
local startColour = Color3.new(0, 1, 0)
local stopColour = Color3.new(1, 0.5, 0)
local fadeTime = 2
local onlineColour = Color3.new(0, 1, 0)
local offlineColour = Color3.new(0, 0, 0)
local lightOnMaterial = Enum.Material.Neon
local lightOffMaterial = Enum.Material.Neon
local damageBlinkStartTime = 0
game:GetService("RunService").RenderStepped:Connect(function(deltaTime: number)
if not isSet then
return
end
local attemptToSet = onlineAmount + (deltaTime / (pumpOnline and timeToStart or -timeToStop))
onlineAmount = math.clamp(attemptToSet, 0, 1)
local effectiveOnlineAmount = onlineAmount * (1 - damageAmount)
script.Parent.Speaker.Sound.PlaybackSpeed = effectiveOnlineAmount * soundMaxPitch
if onlineAmount % 1 ~= 0 then
damageBlinkStartTime = 0
local baseColor = pumpOnline and startColour or stopColour
if prevFadeState ~= pumpOnline then
prevFadeState = pumpOnline
if prevFadeState == nil then fadeCurrentTime = 0 end
end
fadeCurrentTime += deltaTime * effectiveOnlineAmount
for i,v in lights do
local lightAmount = (math.cos(((fadeCurrentTime / fadeTime) + 1/#lights * (#lights - i - 1)) * math.pi * 2) + 1) / 2
local cMut = onlineAmount * lightAmount
v.Color = Color3.new(baseColor.R * cMut, baseColor.G * cMut, baseColor.B * cMut)
end
else
prevFadeState = nil
if pumpOnline == true then
if damageAmount ~= 0 then
if damageBlinkStartTime == 0 then
damageBlinkStartTime = time()
end
local timeOffseted = time() - damageBlinkStartTime
local moduloTimeOffseted = (timeOffseted / 2) % 1
local blinkColour = moduloTimeOffseted <= damageAmount and faultColourBlink or faultColourBlinkOff
print(moduloTimeOffseted)
for i,v in lights do
v.Color = blinkColour
end
else
damageBlinkStartTime = 0
for _,v in lights do
v.Color = onlineColour
end
end
else
for _,v in lights do
v.Color = offlineColour
end
end
end
for _,v in lights do
if v.Color == offlineColour then
v.Material = lightOffMaterial
else
v.Material = lightOnMaterial
end
end
script.Parent.Speaker.Sound.PlaybackSpeed = effectiveOnlineAmount * soundMaxPitch
script.Parent.Speaker.Sound.Playing = effectiveOnlineAmount ~= 0
end)
local pumpDetails = script.Parent.GrabPumpDetails:InvokeServer()
online = pumpDetails.online
onlineAmount = online and 1 or 0
script.Parent.OnlineUpdate.OnClientEvent:Connect(function(newOnlineSignal)
pumpOnline = newOnlineSignal
print("success1")
end)
script.Parent.DamageUpdate.OnClientEvent:Connect(function(newDamageAmount)
damageAmount = newDamageAmount
print("success2")
end)
isSet = trueEditor is loading...
Leave a Comment