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

How can I make this tornado hit others but not hurt me?

Is their a way that this tornado can hit others but not the local player

Note this is a Script

script.Parent.Touched:Connect(function(hit) 
--	local char = player.Character
--	local hum = char:WaitForChild("Humanoid")

	local ehum = hit and hit.Parent:FindFirstChild("Humanoid") 
	if ehum then--and ehum ~= hum then
		ehum:TakeDamage(4)
		print("owu")
	end
end)

2 comments

0

Check if hit.Parent's name isn't yourself.

0

how? i cant say local player.Name.

1 answer

Touched event provides you with the part that touched in it's parameter (Where you have hit). Since hit can be any part, even your character limbs, you would want to check using if-statements to make sure hit's parent (Which could be the character model) isn't your own self.

script.Parent.Touched:Connect(function(hit) 

	--You should check if hit.Parent is a player character before hand too
	local ehum = hit.Parent:FindFirstChild("Humanoid") 
	
	if hit.Parent.Name ~= "Tizzel40" then
		ehum:TakeDamage(4)
		print("owu")
	end
end)

There are also ways to get the Player from the character model using PlayersService:GetPayerFromCharacter(character) but I don't know how relevant that is for this question.

2 comments

0

so if some ones name isnt tizzel and they had the wind element an they use the tornado move, they would sil hurt their self?

0

Yes, that's how this would work right now. You would need to change the string Tizzel40 to the name of the player creating the Tornado.

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