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

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

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

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

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