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

How to get random npc to teleport when script activates?

this script inside tp block

local part = script.Parent

local table = [game.Workspace.NPC1:MoveTo(Vector3.new(-243.135, 7.085, -200.469));
			  game.Workspace.NPC2:MoveTo(Vector3.new(-243.135, 7.085, -200.469));]


local function onPartTouched(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		math.random(table)
		
	end
end

part.Touched:Connect(onPartTouched)

idk how to make table so, could you please script one for me?

3 comments

0

I don't really understand what you want to be done with the script, could you explain it?

0

idk how to make a table to get random npc teleport, so could u make a table that makes random npc tp to the block

0

alright, i answered it

1 answer

✓ Accepted answer

Okay, so you don't actually need a table for this, I see what you're trying to do so here's my attempt to help you

local part = script.Parent

local position = Vector3.new(-243.135, 7.085, -200.469)

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local RandomNum = math.random(1,2)
		game.Workspace:FindFirstChild("NPC"..RandomNum).Humanoid:MoveTo(position)
	end
end)

not entirely sure if this works, but i tried

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