Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get random npc to teleport when script activates?

Asked by 3 years ago
Edited 3 years ago

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?

0
I don't really understand what you want to be done with the script, could you explain it? jorcorrs 76 — 3y
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 Jakob_Cashy 79 — 3y
0
alright, i answered it jorcorrs 76 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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

Ad

Answer this question