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

How do I enable HealthDisplay when a ColorCorrectionEffect is enabled?

Asked by 5 years ago

I made a ColorCorrectionEffect (which I've named Sharingan) and script in which you press Q it enables and when you press Q again it disables, I also made a script that allows players to not see other players/NPC health bars. I want to make a script that combines both of them where if you press Q (enable color effect), only YOU are able to see other players/NPC health bars and once you press Q again (disable color effect) you are no longer able to see players/NPC health. Which means the ColorCorrectionEffect would have to be enabled for the player to be able to see other players/NPC health bars. Any help?

ColorCorrectionEffect script:

local player = game.Players.LocalPlayer
local Humanoid = player.Character:FindFirstChild('Humanoid')
local sharingan = game.Lighting.Sharingan

game:GetService("UserInputService").InputBegan:Connect(function(iobj, gp)
    if gp then
        return 
    end
    if iobj.KeyCode == Enum.KeyCode.Q then
        sharingan.Enabled = not sharingan.Enabled 
    end
end)

HideHealthDisplay script:

local rs = game:GetService("RunService") 
rs.RenderStepped:Connect(function()
    for i,v in ipairs(workspace:GetChildren()) do
        if v:IsA("Model") and v:FindFirstChildOfClass("Humanoid") then
            v:FindFirstChildOfClass("Humanoid").HealthDisplayDistance = Enum.HumanoidHealthDisplayType.AlwaysOff
        end
    end
end)

Answer this question