Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Tizzel40 243 Moderation Voter
5 years ago

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)
0
Check if hit.Parent's name isn't yourself. xPolarium 1388 — 5y
0
how? i cant say local player.Name. Tizzel40 243 — 5y

1 answer

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago

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.

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? Tizzel40 243 — 5y
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. xPolarium 1388 — 5y
Ad

Answer this question