I'm trying to make a Low HP Blur local script, but it won't work. I don't know why! It shows no errors, but there is one and it isn't being pointed out by ROBLOX Studio at all. Not even the output logs/developer console points the error out.
P.S: The local script is in a folder, and so is the blur effect
Script:
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() local effect = script.Parent.Blur cam = workspace.CurrentCamera effect.Parent = cam if char.Humanoid.Health <= 30 then effect.Enabled = true elseif char.Humanoid.Health > 30 then effect.Enabled = false end
You may want to connect this to the HealthChanged event of the Humanoid. Otherwise, this will only fire once.
Also, since you probably want to restart this effect every time the player dies, you should have this under StarterCharacterScripts so that it spawns with the Character. You can also try using the CharacterAdded event for this, though in that case it won't be in StarterCharacterScripts, but instead it will be in StaterPlayerScripts.
Here's how I would probably write the script:
-- Parent this to StarterCharacter. The blur is a child of this script that may be -- cloned to CurrentCamera if it hasn't been yet. It's named "HealthBlur" local Character = script.Parent local HealthBlurBase = script:WaitForChild("HealthBlur") local Humanoid = Character:WaitForChild("Humanoid") local CurrentCamera = workspace.CurrentCamera local HealthBlur = CurrentCamera:FindFirstChild("HealthBlur") if not HealthBlur then HealthBlur = HealthBlurBase:Clone() HealthBlur.Parent = CurrentCamera end HealthBlur.Enabled = false local function UpdateHealthBlur(newHealth) if newHealth > 30 then HealthBlur.Enabled = false else HealthBlur.Enabled = true end end Humanoid.HealthChanged:Connect(UpdateHealthBlur) UpdateHealthBlur(Humanoid.Health)
As a design choice, the blur should probably be triggered at a certain percentage of max health.