Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Damage not being done Via Raycast?

Hello,

So, this use to work till I added Tween to the raycast to simulate a moving projectile.

I am not getting any output at all and its kinda annoying. Was wondering if anyone here might have a general idea of where I went wrong.

	if hit then
		print("Found Person")
    	local humanoid = hit.Parent:FindFirstChild("Humanoid")
 		if humanoid and humanoid:FindFirstChild("Health") then
			print("Hitting Person")
    		if hit.Name == "Head" then
				humanoid.Health:TakeDamage(Head)
			elseif hit.Name == "Torso" then
				humanoid.Health:TakeDamage(Torso)
			else
				humanoid.Health:TakeDamage(Limb)
			end
		end
	end

1 answer

✓ Accepted answer

Hello, Decimaprism!

Your problem is basically humanoid don't have a child called Health, it have a Property called Health

And :TakeDamage() gets a FloatValue as argument

if hit then
    print("Found Person")
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        print("Hitting Person")
        if hit.Name == "Head" then
            humanoid:TakeDamage(Head)
        elseif hit.Name == "Torso" then
            humanoid:TakeDamage(Torso)
        else
            humanoid:TakeDamage(Limb)
        end
    end
end

Please don't post duplicate questions

Good Luck with your games

This discussion is preserved as it was. New answers, comments, and votes are closed.