• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


29 Nov, 2024

Updated at 02 Dec, 2024

Script not identifying part properly

i have an enemy NPC. this script is to make the NPC play a slide animation once its head is hit by something in order to be able to move through spaces with low tops. there’s an if-then statement that detects if the hit part is NOT parented to the NPC model, but it doesn’t work.

every time there’s an animation that plays that involves the head touching a part of the body a bit, the slide animation unintentionally plays, which makes the NPC perform such an abomination of a dance that breaks all rules of the universe.

take note that i also tried setting the CanTouch property of some body parts to be false, but it didn’t work. some body parts also need to have CanTouch on at all times since they also need to detect touch for their own lil functions.

nothing in the dev console btw

local me = script.Parent
local hum = me.Humanoid
local anim = hum.slide
local animer = hum.Animator
local track = animer:LoadAnimation(anim)
local head = me.Head
local debounce = false

head.Touched:Connect(function(hit)
	if debounce == false then
		if hit.Parent ~= me then
			debounce = true
			me.patterns.Enabled = false
			track:Play()
			wait(track.Length)
			me.patterns.Enabled = true
			debounce = false
		end
	end
end)

2 posts - 2 participants

Read full topic