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

How do I make it not damage the player who casted it?

	grandFireball.Touched:Connect(function(Touched)
		if Touched.Parent.Name ~= player.Name then
		local Humanoid
		if Touched.Parent:IsA("Accessory")then
			Humanoid = Touched.Parent.Parent.Humanoid
		elseif Touched.Parent:IsA("Model")then
			Humanoid = Touched.Parent.Humanoid
		end
		if Humanoid ~= nil then
				Humanoid:TakeDamage(5)
				grandFireball:Destroy()
			end
		end
	end)

The script works and damages the dummies however I was testing and to see if it would damage me and it does and I do not want that happening.

1 answer

The possible reason why is because you are checking if

Touched.Parent.Name ~= player.Name

In this case you except Touched to be part which is children of the character, but the thing is that characters also have Accessories which have handles in them, handles also have hitbox but they are not parent of character, they are parent of the accessory and descendant of character. So to fix this, what you could do is:

grandFireball.Touched:Connect(function(Touched)
	if not Touched:IsDescendantOf(player.Character) then

What this does is that it checks if the hit is descendant of player's character. basically descendants in roblox are parts that are located in some object, by that i mean:

/Workspace -- Descendant of game and also child of game
	/Part -- Descendant of Workspace and game
		/AnotherPart -- Descendant of Workspace, Part and game
/ReplicatedStorage -- Descendant and also child of game
	/Folder -- Descendant of ReplicatedStorage and game but not descendant of Workspace

2 comments

0

Ah okay

0

Please accept the answer @LL0YD01

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