Yes, I know what you're thinking; "This is so easy, health is not a valid member of a model!".
But, I used the FindFirstChild() function, but still, it doesn't work.
Client script: (Local script, inside tool)
tool = script.Parent player = game.Players.LocalPlayer tool.Equipped:Connect(function(mouse) mouse.Icon = "http://www.roblox.com/asset/?id=2312592107" mouse.Button1Down:Connect(function() game.Workspace.KillExplosion.KillExplosionCreate:FireServer(mouse.Target, tool.Handle) end) end)
Server script: (Normal script, inside workspace)
debounce = false script.KillExplosionCreate.OnServerEvent:Connect(function(player, target, tool) if debounce == false and target.Parent:FindFirstChild("Humanoid") then debounce = true tool.BrickColor = BrickColor.new("Really red") player = target.Parent.Humanoid player.Health = player.Health - 18 wait(1) debounce = false tool.BrickColor = BrickColor.new("Sea green") end end)
I have no idea why this doesn't work. So, when I click on something that doesn't have a Humanoid I get the error:
Health is not valid member of Model
BUT I USED THE FIND FIRST CHILD FUNCTION! WHY??!!
ERROR AT LINE 8, SERVER SCRIPT
Model does not contain a Health value. You're trying to change the .Health property of a Model. Health is a property of Humanoid. Try going down/up the Hierarchy and find the Humanoid of the Player.
If you get the error when clicking something without a humanoid, try using if [object]:FindFirstChild("Humanoid") then. It will only execute the remaining code in it's block if it can find a Humanoid. This should eliminate the error.
According to your error, Humanoid is the name of the Model. If :FindFirstChild() isn't working for you, try using object:IsA("Humanoid") then. If it's a model, it won't continue. But if the object is a Humanoid, the code will continue.
I don't quite understand what you're trying. Please contact me in Discord. I can further assist you there.
Bark#4260