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

How to use a Touched function on a group of parts?

die=game.Workspace.Stage1.Kills:GetChildren()
active=false
part2=game.Workspace.Stage1.Start1


die.Touched:connect(function(leg)
	if leg.Parent.Humanoid ~= nil then
		if active == false then
			active=true
			local hum=leg.Parent:WaitForChild("Humanoid")
			local char=hum.Parent
			local end1=part2.Position+Vector3.new(0,3,0)
			char.Torso.CFrame=CFrame.new(end1)
		else return end
		wait(1.5)
		active=false
	end
end)

Die is all the things that kill you (teleport). And it says "Touched' (a nil value)" and Idk what to do now. I want to make it so when I touch a part that is inside that model, It starts the function

2 comments

0

I also don't want to add a script to each of the parts

0

mb Touched event* not function

1 answer

✓ Accepted answer

Well, you could just use a loop to connect each part's Touched event to that function.

die=game.Workspace.Stage1.Kills:GetChildren()
active=false
part2=game.Workspace.Stage1.Start1

function doThings(leg)
	if leg.Parent.Humanoid ~= nil then
    	if active == false then
        	active=true
        	local hum=leg.Parent:WaitForChild("Humanoid")
        	local char=hum.Parent
        	local end1=part2.Position+Vector3.new(0,3,0)
        	char.Torso.CFrame=CFrame.new(end1)
    	end
    wait(1.5)
    active=false
    end
end

for _, part in pairs(die) do
	part.Touched:connect(doThings)
end

3 comments

0

ServerScriptService.kill:19: attempt to call a table value

0

fixed

1

yay ty

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