Faulty if statement with Touched function

There is probably a generic solution to this that I’m not thinking of, but I’m confused!

I’m trying to get the script to detect the player and a hitbox that spawns when the player dodges. Why do I want to find both just to blind them with sand? Testing. Anyways, I’m having trouble when the If statement tries to detect 2 or more objects touched. I can’t find a solution after scowering the internet for 1-2 hours.

Hitbox.Touched:Connect(function(hit)
local hitplayer = game.Players:GetPlayerFromCharacter(hit.Parent)
local humanoid = hit.Parent:FindFirstChildOfClass(“Humanoid”)
if hitplayer and hit.Name == (“Dodged”) then
BlurEffect:FireClient(hitplayer)
humanoid.WalkSpeed = 2
task.wait(3)
humanoid.WalkSpeed = 16
end
end)

1 Like

You cen check for whenever the player is touching the collisions it does a check if it is already inside a box :

  1. make a variable called touching collision
  2. when player touched set collision to true
  3. if player is touched then collision = true and run code
  4. player stopped touching ? then collision = false

thanks :smiley:

1 Like

I guess I could just get the rootpart. Also, I’ve already tried a solution like that for nothing to execute.

1 Like

oh no i guess you can do smthign like this

inside of the charachte put this

script.parent.touched:connect(function)
if Hit.name = collision box then
do the code

1 Like

add a string value containing the owner to make it work idk ?

1 Like