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

Touched functions not working with unions?

When a player touches a union with this script it does not seem to run

local Body = {"Right Leg","Left Leg","Torso","Right Arm","Left Arm"}
while wait(.0125) do


	for i,v in pairs(Body) do
		wait()
			player.Character:WaitForChild(v).Touched:connect(function(touched)
				if not activated then
					activated = true
					if touched ~= nil and touched.Name ~= "Base" and touched:IsA("Part")  or
						touched ~= nil and touched.Name ~= "Base" and touched.Name ~= "Part" and touched:IsA("Union") then
						 local CheckDone = CheckTouched(touched)
						if game.Workspace:WaitForChild(player.Name).Humanoid.Health <= 0 then
							script.Parent.DeathSound:Play()
						end
					repeat wait(.1) until CheckDone == true
					end
					activated = false
				end
				
					
		
			end)
		
	end
end

When a player touches a union it does not seem to run.

1 comment

0

What is it touching? This script will only run if it tuches itself.

1 answer

local Body = {"Right Leg","Left Leg","Torso","Right Arm","Left Arm"}
while wait(.0125) do
    for i,v in pairs(Body) do
        wait()
            player.Character:WaitForChild(v).Touched:connect(function(touched)
                if not activated then
                    activated = true
			if touched and touched.Name ~= "Base" and (touched:IsA("Part") or 
			touched:IsA("Union")) then
                         local CheckDone = CheckTouched(touched)
                        if game.Workspace:WaitForChild(player.Name).Humanoid.Health <= 0 then
                            script.Parent.DeathSound:Play()
                        end
                    repeat wait(.1) until CheckDone == true
                    end
                    activated = false
                end
            end)
    end
end

I rewrote your if statement, see if it works now.

1 comment

0

Still does not seem to run

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