Im just trying to mess around with .Changed because I've never used it. Can Anyone fix this please? :D
local Player = game.Players.LocalPlayer local Character = (function() repeat wait() until Player.Character return Player.Character end)() local camera = game.Workspace.CurrentCamera local FOV = 70 character.Humanoid.Changed:connect(function(Change) if Change:match("Health") then FOV = FOV -70 camera.FieldOfView = FOV end end)
Easy, instead of using :match()
just check if Change == "Health"
. Another problem was that Character on line 2 had a Capital C and the other character on line 5 had a lower cased one. Also, the minimum value for FOV is 1, it cannot go over 120 or under 1.
local Player = game.Players.LocalPlayer local Character = (function() repeat wait() until Player.Character return Player.Character end)() local camera = game.Workspace.CurrentCamera local FOV = 70 Character.Humanoid.Changed:connect(function(Change) if Change == "Health" then FOV = FOV -69 camera.FieldOfView = FOV end end)
If you want it so that if a player dies then use the Died event.
BTW I revised your whole script.
local Player = game.Players.LocalPlayer local Character = (function() repeat wait() until Player.Character return Player.Character end)() local camera = game.Workspace.CurrentCamera Character.Humanoid.Changed:connect(function(Change) if Change == "Health" then camera.FieldOfView = 1 end end)
Hope this helps!
local Player = game.Players.LocalPlayer local Character = Player.CharacterAdded:wait() local Humanoid = Character:WaitForChild("Humanoid") local Camera = game.Workspace.CurrentCamera local currentHealth = Humanoid.Health Humanoid.HealthChanged:connect(function(health) local change = math.abs(currentHealth - health) if currentHealth > health then --health decreased! print(change.."damage") else --health increased print(change.."heal") end currentHealth = health end)