I need a quick few tips on how to get a Humanoid when the Mouse Cursor is pointed at the Model as you point at the Zombie (model) and it shows the GUI of the HP of that zombie.
All I need right now is to get the Humanoid from Pointing the mouse at the model. I've never used something like that in scripts.
This is what I've done so far:
wait(0.5) local char = game:GetService("Players").LocalPlayer.Character -- I need to make this variable to change to the Model Humanoid EVERYTIME you point at the "Zombie". local hum = char.Humanoid hum.Changed:Connect(function() script.Parent.Frame.Health.Frame.Size = UDim2.new(hum.Health / hum.MaxHealth, 0, 1, 0) script.Parent.Frame.Text.TextLabel.Text = math.floor(hum.Health) .. "/" .. hum.MaxHealth if hum.Health <= hum.MaxHealth * 0.15 then script.Parent.Frame.Health.Frame.BackgroundColor3 = Color3.new(150 / 255, 0, 0) else script.Parent.Frame.Health.Frame.BackgroundColor3 = Color3.new(0, 220 / 255, 0) end end)
Check out the wiki article for some info. To detect you could do something like (this is just an example):
local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local current_zombie = nil mouse:GetPropertyChangedSignal("Target"):Connect(function(hit) if hit.Parent.Name == "Zombie" then -- somehow check that it's a part in the zombie if hit.Parent == current_zombie then -- check if this zombie is already targeted -- do nothing (keep showing gui) else current_zombie = hit.Parent -- remove any existing gui -- show new gui end else current_zombie = nil -- remove any existing gui end end)