Morph kill script wont work

I’m trying to add a custom morph to my Piggy fangame, but the kill script won’t work. On every morph the kill script works fine. In this morph, it’ll either
Kill yourself, or kill only 1 person.

Kill script:

local animKill = script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.Parent.Swing)

local bs = game:GetService("BadgeService")

local id = 3087677870210396

debounce = false

Dummy.Hitbox.Touched:Connect(function(IsAPlayer)
	print("Someone touched remote")
	if debounce == false then
		if game.Players:FindFirstChild(IsAPlayer.Parent.Name) then
			local player = game.Players:GetPlayerFromCharacter(IsAPlayer.Parent)
			if IsAPlayer.Parent.Name == Dummy.Name then
				print("trying to oof myself..")
			else
				animKill:Play()
				--bs:AwardBadge(player.UserId, id)
				debounce = true
				game.ReplicatedStorage.TIOAttackCamera:FireClient(player, Dummy.Camera)
				local InJumpscare = Instance.new("BoolValue", IsAPlayer)
				InJumpscare.Name = "InJumpscare"
				IsAPlayer.Parent.HumanoidRootPart.Anchored = true
				Dummy.HumanoidRootPart.Ambience.Playing = false
				task.wait(0.25)
				Dummy.HumanoidRootPart.Anchored = true
				animKill:GetMarkerReachedSignal("Hit"):Connect(function()
					Dummy.ShovelHit:Play()
				end)
				animKill:GetMarkerReachedSignal("Scream"):Connect(function()
					Dummy.Scream:Play()
					task.wait(0.5)
					if IsAPlayer then
						IsAPlayer.Parent.HumanoidRootPart.Anchored = false
						IsAPlayer.Parent.Humanoid.Health = 0
					end
					task.wait(1)
					Dummy.HumanoidRootPart.Ambience.Playing = true
					Dummy.HumanoidRootPart.Anchored = false
				end)
				debounce = false
			end
		end
	end
end)
1 Like

Alright so, checking your script I have some doubts; what’s "dummy"? and what do you specifically want to do upon something touches the hitbox?

Dummy is the morph model. And the specific thing is basically the jumpscare

Where have you defined “Dummy”? Try to rewrite your code here.

--// Services
local BadgeService = game:GetService("BadgeService")

--// Vairables
local animKill = script.Parent.Parent:FindFirstChild("Humanoid"):LoadAnimation(script.Parent.Parent.Swing)
local id = 3087677870210396
local debounce = false

--// Code
Dummy.Hitbox.Touched:Connect(function(hit)
	
	print("Someone touched remote")
	
	if debounce == false then
		
		debounce = not debounce -- inverse value of debounce
		
		if hit.Parent.Name ~= Dummy.Name then
			
			if game.Players:FindFirstChild(hit.Parent.Name) then
				
				-- your code here
				
			end
		end
		
		debounce = not debounce -- inverse value of debounce
		
	end
end)```

local Dummy = script.Parent.Parent
local animKill = script.Parent.Parent:FindFirstChild(“Humanoid”):LoadAnimation(script.Parent.Parent.Swing)

local bs = game:GetService(“BadgeService”)

local id = 3087677870210396

debounce = false