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

How can I clone a NPC in a custom position?

Asked by 4 years ago
Edited 4 years ago

Hello, I'm trying to make a button that clone an NPC in a custom position, I tried CFrame and Vector3 but it can't clone the NPC in a right position, it alway spawn at the position I placed it in the workspace, so how can I make a script that can clone NPC in a custom position?

My script :

local click = script.Parent.ClickDetector
local button = script.Parent
local npc = game.ServerStorage.NPCs.NPC

click.MouseClick:Connect(function()
    if not script.Parent.Parent:FindFirstChild("NPC") then
        local cloneNPC = npc:Clone()
        cloneNPC.Torso.CFrame = CFrame.new(script.Parent.Parent.Parent.Spawner.Position)
        cloneNPC.Parent = button.Parent
    else
            print("Clear before spawn another!")
    end
end)

Can anyone give me a tips?

Answer this question