Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't the beam change color when it's health hit's a certain fraction?

Asked by 3 years ago
-- Variables for the bosses

local CheemS = script.Parent.Cheems
local CheemsHealth = CheemS.Boss.Health
local BigDoge = script.Parent["Buff Doge"]
local CheemsSoundId = "rbxassetid://170278900"
local BigDogeSoundId = "rbxassetid://7128572620" -- I KNOW THIS SOUNDS FROM WARFRAME NOW SHUT UP PLEASE!!!!!!!!!
local CheFourth = CheemS.Boss.MaxHealth/4
local CheThird = CheemS.Boss.MaxHealth/3
local CheHalf = CheemS.Boss.MaxHealth/2
local AlmostDead = CheemS.Boss.MaxHealth/10
-- Functions

CheemS.Boss.Died:Connect(function() -- If cheems dies destroy buff doges forcefield
    local CheemsSound = Instance.new("Sound")
    CheemsSound.SoundId = CheemsSoundId
    CheemsSound.Parent = CheemS.HumanoidRootPart
    CheemsSound.PlayOnRemove = true
    CheemsSound.Volume = 2.5
    CheemsSound.RollOffMaxDistance = 4800
    CheemsSound:Destroy()
    local KaBOOM = Instance.new("Explosion")
    KaBOOM.Parent = CheemS.HumanoidRootPart
    KaBOOM.Position = CheemS.HumanoidRootPart.CFrame.Position
    KaBOOM.BlastPressure = 350000
    KaBOOM.DestroyJointRadiusPercent = 0
    KaBOOM.BlastRadius = 0.5
    BigDoge.ForceField:Destroy() -- got it
    local KaBOOM = Instance.new("Explosion")
    KaBOOM.Parent = BigDoge.HumanoidRootPart
    KaBOOM.Position = BigDoge.HumanoidRootPart.CFrame.Position
    KaBOOM.BlastPressure = 0
    KaBOOM.DestroyJointRadiusPercent = 0
    local ShieldDownSound = Instance.new("Sound")
    ShieldDownSound.SoundId = BigDogeSoundId
    ShieldDownSound.Parent = BigDoge.HumanoidRootPart
    ShieldDownSound.Volume = 3.45
    ShieldDownSound.RollOffMaxDistance = 1500
    ShieldDownSound.PlayOnRemove = true
    ShieldDownSound:Destroy()
    CheemS.HumanoidRootPart.Beam:Destroy()
end)

BigDoge.Boss.Died:Connect(function() -- It seems buff doge has died
    local KaBOOM = Instance.new("Explosion")
    KaBOOM.Parent = BigDoge.HumanoidRootPart
    KaBOOM.Position = BigDoge.HumanoidRootPart.CFrame.Position
    KaBOOM.BlastPressure = 806000
    KaBOOM.BlastRadius = 0.1
    KaBOOM.DestroyJointRadiusPercent = 0
    wait(5)
    script.Parent.Link:Destroy()
    BigDoge.AI:Destroy()
    CheemS.AI:Destroy()
end)

CheemS.Boss.HealthChanged:Connect(function(CheemsHealth)
    if CheemsHealth <= CheHalf then
        CheemS.HumanoidRootPart.Beam.Color = ("Really Blue")
    end

    if CheemsHealth <= CheThird then
        CheemS.HumanoidRootPart.Beam.Color = ("Neon Orange") -- i'm having problems here
    end
    if CheemsHealth <= CheFourth then
        CheemS.HumanoidRootPart.Beam.Color = ("Really Red")
    end
    if CheemsHealth <= AlmostDead then
        CheemS.HumanoidRootPart.Beam.Color = ("Really Black")
    end


end)

I tried to make a script that makes the beam change color when an npc is at a certain amount of health it says nothing in the output but the script doesn't work for some reason i tried using elseifs but it would give a script error how do i fix this? also ignore the other lines lol

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

u see my dude the thing about beams is that theres a special way to set their color and this is how u do it

local color_of_the beam = Color3.fromRGB() -- u can set the color of the beam here (but it has to be set in numbers not in letter like u did)
local color_sequence_of_the_beam = ColorSequence.new{ 
ColorSequenceKeypoint.new(0,color_of_the beam),
ColorSequenceKeypoint.new(1,color_of_the beam)
}

--so after u created the sequence in yur case u can set the color of yur beam like this

CheemS.HumanoidRootPart.Beam.Color = color_sequence_of_the_beam


hope this helped

Ad

Answer this question