Ok. So continuing with my experimentation I decide that as all the blue Bots need to be facing forwards I would move the model to workspace, use the Studio rotation tool and move it back to ReplicatedStorage and comment out the rotation code used to get both blue Bots facing forwards.
The orientation for the right hand turn now works but both blue Bots are facing upwards, not forward as expected.
I have attached two more pics. One showing the blue Bot model facing forward and the other the end of test run.
Here is the adjusted code
print("Hello world!")
local Players = game:GetService("Players")
local LP = Players.LocalPlayer
local PlrGui = LP:WaitForChild("PlayerGui")
local PN = LP.Name
print ("PlayerName="..PN)
local AP = workspace:WaitForChild(PN)
local HRP = AP:WaitForChild("HumanoidRootPart")
local Controller = script.Parent
local color1 = Color3.fromRGB(251,255,183)
local color2 = Color3.fromRGB(255,255,15)
local colorSeq = ColorSequence.new(color1,color2)
local parts = {}
local BeamOFF = NumberSequence.new({
NumberSequenceKeypoint.new(0,1),
NumberSequenceKeypoint.new(0.5,1),
NumberSequenceKeypoint.new(1,1),})
local function scanWeld(parent,Bot)
for _,v in pairs(parent:GetChildren()) do
if (v:IsA("BasePart")) then
if v.Name ~= "MainPart" then
local w = Instance.new("WeldConstraint")
w.Name = ("WC_%s"):format(v.Name)
w.Part0 = Bot.MainPart
w.Part1 = v
w.Parent = Bot.MainPart
table.insert(parts,v)
scanWeld(v)
wait(0.05)
end
end
end
end
Controller.Equipped:Connect(function()
print("Equiping")
local waits = 3
local RS = game:GetService("ReplicatedStorage")
local APLTCF = AP.LowerTorso.CFrame
local Controller = AP:WaitForChild("Controller")
local Handle = Controller:WaitForChild("Handle")
print("Handle set Wait")
wait(waits)
local BotMaster = RS.BotMaster:Clone()
BotMaster.Parent = Handle
local BotMasterOffset = Vector3.new(-0.5,0,-1.25)
local BotMasterOrientation = CFrame.Angles(0,0,math.rad(90))
local APLTCF = AP.LowerTorso.CFrame
local BotMainPartCFrameAdjustment = APLTCF + APLTCF.lookVector + BotMasterOffset
BotMaster:SetPrimaryPartCFrame(BotMainPartCFrameAdjustment)
local orientBot = BotMaster:GetPrimaryPartCFrame() * BotMasterOrientation
BotMaster:SetPrimaryPartCFrame(orientBot)
print("BotMasterLookVector=",BotMaster.MainPart.CFrame.LookVector)
scanWeld(BotMaster, BotMaster)
for _,v in pairs(parts) do
v.Anchored = false
end
local w1 = Instance.new("WeldConstraint")
w1.Part0 = Handle
w1.Part1 = BotMaster.MainPart
w1.Name = "WC_BotMaster"
w1.Parent = Handle
BotMaster.MainPart.Anchored = false
print("BotMaster Anchoring Wait")
wait(waits)
local beam = Instance.new("Beam")
beam.FaceCamera = true
beam.Attachment0 = AP.UpperTorso.BodyFrontAttachment
beam.Width0 = 0.2
beam.Attachment1 = BotMaster.MainPart.Attachment
beam.Width1 = 0.2
beam.Color = colorSeq
beam.Name = "Beam_BotMaster"
beam.Parent = AP.UpperTorso
print("BotMaster Beam Wait")
wait(waits)
AP.UpperTorso:WaitForChild("Beam_BotMaster").Transparency = BeamOFF
local Bot = RS.Bot:Clone()
wait(1)
print("BotLookVectorB4=",Bot.MainPart.CFrame.LookVector)
local BotMainPartCFrameAdjustment = CFrame.new(0,0,0)
local BotOffset = Vector3.new(0,-0.25,-6)
local OffsetDiff = APLTCF.LookVector + BotOffset
BotMainPartCFrameAdjustment = APLTCF + APLTCF.LookVector + BotOffset
Bot:SetPrimaryPartCFrame(BotMainPartCFrameAdjustment)
print("BotLookVectorAfterSetPrimaryPartCFrame=",Bot.MainPart.CFrame.LookVector)
-- local BotOrientation = CFrame.Angles(-math.rad(90),0,0)
-- print("BotOrientationCFrame=",BotOrientation)
-- local orientDigaBot = Bot:GetPrimaryPartCFrame() * BotOrientation
-- print("orientDigBotCFrame=",orientDigaBot)
-- Bot:SetPrimaryPartCFrame(orientDigaBot)
Bot.Parent = BotMaster
print("BotLookVectorAftr=",Bot.MainPart.CFrame.LookVector)
print("Bot Parented Wait")
wait(waits)
scanWeld(Bot, Bot)
for _,v in pairs(parts) do
v.Anchored = false
end
local w2 = Instance.new("WeldConstraint")
w2.Part0 = AP.LowerTorso
w2.Part1 = Bot.MainPart
w2.Name = "WC_Bot"
w2.Parent = BotMaster
Bot.MainPart.Anchored = false
print("Bot Anchoring Wait")
wait(waits)
local beam = Instance.new("Beam")
beam.FaceCamera = true
beam.Attachment0 = BotMaster.Screen.Attachment
beam.Width0 = 0.2
beam.Attachment1 = Bot.MainPart.Attachment
beam.Width1 = 0.2
beam.Color = colorSeq
beam.Name = "Beam_Bot"
beam.Parent = BotMaster
print("Bot Beam Wait")
wait(waits)
BotMaster:WaitForChild("Beam_Bot").Transparency = BeamOFF
local Bot2 = RS.Bot:Clone()
wait(1)
print("Bot2LookVectorB4=",Bot2.MainPart.CFrame.LookVector)
local Bot2MainPartCFrameAdjustment = CFrame.new(0,0,0)
local Bot2Offset = Vector3.new(3.75,-0.25,-3.75)
local OffsetDiff2 = APLTCF.LookVector + Bot2Offset
Bot2MainPartCFrameAdjustment = APLTCF + APLTCF.LookVector + Bot2Offset
Bot2:SetPrimaryPartCFrame(Bot2MainPartCFrameAdjustment)
print("Bot2LookVectorAfterSetPrimaryPartCFrame=",Bot2.MainPart.CFrame.LookVector)
-- local Bot2Orientation1 = CFrame.Angles(-math.rad(90),0,0) -- same as bot1
local Bot2Orientation2 = CFrame.Angles(0,math.rad(45),0) -- same as bot1 with right turn 45
-- print("Bot2OrientationCFrame1=",Bot2Orientation1)
print("Bot2OrientationCFrame2=",Bot2Orientation2)
local orientDigaBot2 = Bot2:GetPrimaryPartCFrame() * Bot2Orientation2 --* Bot2Orientation1
print("orientDigBot2CFrame=",orientDigaBot2)
Bot2:SetPrimaryPartCFrame(orientDigaBot2)
-- Bot2.Parent = BotMaster
-- print("Bot2LookVectorSameAsBot1?",Bot2.MainPart.CFrame.LookVector)
-- wait(waits)
-- local Bot2ApplyRotationCFrame = CFrame.Angles(0,0,-math.rad(45)) -- right 45 using Z ??? Pic1
-- local Bot2ApplyRotationCFrame = CFrame.Angles(0,math.rad(45),0) -- right 45 using Y ??? Pic2
-- local Bot2CFrame = Bot2:GetPrimaryPartCFrame()
-- local Bot2PositionCFrame = CFrame.new(Bot2CFrame.p)
-- local Bot2RotationCFrame = Bot2CFrame - Bot2CFrame.p
-- orientDigaBot2 = Bot2PositionCFrame*Bot2ApplyRotationCFrame*Bot2RotationCFrame
-- Bot2:SetPrimaryPartCFrame(orientDigaBot2)
Bot2.Parent = BotMaster
-- print("Bot2LookVectorAfterSecondOrientation=",Bot2.MainPart.CFrame.LookVector)
print("Bot2 Parented Wait")
-- wait(waits)
scanWeld(Bot2, Bot2)
for _,v in pairs(parts) do
v.Anchored = false
end
local w3 = Instance.new("WeldConstraint")
w3.Part0 = AP.LowerTorso
w3.Part1 = Bot2.MainPart
w3.Name = "WC_Bot2"
w3.Parent = BotMaster
Bot2.MainPart.Anchored = false
print("Bot2 Anchoring Wait")
wait(waits)
local beam = Instance.new("Beam")
beam.FaceCamera = true
beam.Attachment0 = BotMaster.Screen.Attachment
beam.Width0 = 0.2
beam.Attachment1 = Bot2.MainPart.Attachment
beam.Width1 = 0.2
beam.Color = colorSeq
beam.Name = "Beam_Bot2"
beam.Parent = BotMaster
print("Bot2 Beam Wait")
wait(waits)
BotMaster:WaitForChild("Beam_Bot2").Transparency = BeamOFF
print("Equiped")
end)