What did I do wrong? OnTouch was working before. I'm missing something

Hey there. This is a relatively simple script. As soon as the player hits the part (which enclosed is the localscript with the following code) the OnTouch should fire and play the paused audio (audio was paused via another LocalScript) and also play the animation. I’m missing something I believe. This code is a jumbled mess of me trying to come up with solutions, so if someone could simplify it, that would be great.

local animTrack = game.Workspace.UFO.Humanoid:LoadAnimation(UFO)
local UFOmodel = game.Workspace.UFO
local MaleVoiceover = game.Workspace.Sound.MaleVoiceover
local canTouch = game.Workspace.UFOevent.CanTouch


local function onTouch (hit)
	    canTouch.Enabled = false
		wait(.1)
		MaleVoiceover:Resume()
		animTrack:Play()
		wait(9)
	    UFOmodel:Destroy()
end
script.Parent.Touched:Connect(onTouch)```
1 Like

Any errors? If so what do they say?

No errors at all, unfortunately. That is why it is so puzzling to me.

Change canTouch.Enabled = false to canTouch = false since CanTouch in parts are just a true or false check box.

That’s all I really see I don’t know much about animations and sounds are weird from time to time. Lmk if that helps at all.

Also, I recommend adding

if hit.Parent:FindFirstChild("Humanoid") then
end

Inside the function and putting the code into the if statement so it just doesn’t go off when it hits something like the floor.