My friend and me are working on a boss npc fella and my friend coded this thing up but when he tried to add like tween to it, the bosses’ humanoidrootpart is being detached and fly’s away by itself.
Here’s the clip.
Here’s the function of the script:
function randomMoveToPlate()
local ChosenPlate = game.Workspace.Map.Plates:GetChildren()[math.random(1,#game.Workspace.Map.Plates:GetChildren())]
repeat
wait()
ChosenPlate = game.Workspace.Map.Plates:GetChildren()[math.random(1,#game.Workspace.Map.Plates:GetChildren())]
until ChosenPlate.Name ~= "Map"
local minX = -ChosenPlate.Part.Size.X / 2 - 12
local maxX = ChosenPlate.Part.Size.X / 2 + 12
local minZ = -ChosenPlate.Part.Size.Z / 2 - 12
local maxZ = ChosenPlate.Part.Size.Z / 2 + 12
local minY = -ChosenPlate.Part.Size.Y / 2
local maxY = ChosenPlate.Part.Size.Y / 2 + 50
local pos = ChosenPlate.Part.Position + Vector3.new(math.random(minX,maxX),math.random(minY,maxY),math.random(minY,maxY))
local Cpos = ChosenPlate.Part.CFrame * CFrame.new(math.random(minX,maxX),math.random(minY,maxY),math.random(minY,maxY))
--script.Parent:SetPrimaryPartCFrame(CFrame.lookAt(script.Parent.Torso.Position, pos))
tw:Create(script.Parent.HumanoidRootPart, TweenInfo.new(speed.Value, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Position = pos}):Play()
end