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

Why it takes time to detect other's HumanoidRootPart and how can I fix it?

Asked by 3 years ago

There is a Hitbox Part which set CanColide to false,Anchored. It teleports to certain area and removes 0.1sec later,detecting touched parts and unions. When I test it, It only detects my character's parts only. Few secs later,it starts to detect other humanoid's HumanoidRootPart too,not head and other parts. I dont want delay to make hitbox work successfully. How can I fix it to detect head or etc? How can I fix it to detect them without delay?

1 answer

Log in to vote
0
Answered by 3 years ago

Hey there! I'm not sure if I am interpreting your question correctly. However, here is a few tips that can help with detecting a player.

Inside of your hitbox part, add this script. It will help detect the player.

script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then -- If there is a person, the script will continue
        local humanoid = part.Parent.Humanoid -- "humanoid" is now the characters humanoid.
        ---write other scripts here
    end
end)

The only problem with this script is that it will run over and over until the player is no longer touching the brick. To teleport the player, try this script:

script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then -- If there is a person, the script will continue
        local humanoid = part.Parent.Humanoid -- "humanoid" is now the characters humanoid.
        part.Parent.HumanoidRootPart.CFrame = CFrame.new(position) --change position to where you want to be teleported to
    end
end)

I hope this helps! Feel free to ask any questions

Ad

Answer this question