Hello, thank you for taking the time to read this. Anyways.
I have everything correctly set up in workspace. Yet Im getting a error? Its probably a stupid little mistake on my part.
Links: http://prntscr.com/bra09p
My error:
Workspace.Script:40: bad argument #1 to '?' (CFrame expected, got nil) Script 'Workspace.Script', Line 40 Stack End
My code:
local mod = workspace.Model
local run = game:GetService("RunService")
local pos = {
16,
16,
16
}
local old_rots = {
['Left'] = workspace.Model.Left.Light.Movement.CFrame;
['Right'] = workspace.Model.Right.Light.Movement.CFrame;
['Middle'] = workspace.Model.Middle.Light.Movement.CFrame;
}
print(type(old_rots[1])) -- -> "nil"
local function clerp(p1,p2,percent)
local p1x,p1y,p1z,p1R00,p1R01,p1R02,p1R10,p1R11,p1R12,p1R20,p1R21,p1R22=p1:components()
local p2x,p2y,p2z,p2R00,p2R01,p2R02,p2R10,p2R11,p2R12,p2R20,p2R21,p2R22=p2:components()
return CFrame.new(p1x+percent*(p2x-p1x),p1y+percent*(p2y-p1y),p1z+percent*(p2z-p1z),
p1R00+percent*(p2R00-p1R00),p1R01+percent*(p2R01-p1R01),p1R02+percent*(p2R02-p1R02),
p1R10+percent*(p2R10-p1R10),p1R11+percent*(p2R11-p1R11),p1R12+percent*(p2R12-p1R12),
p1R20+percent*(p2R20-p1R20),p1R21+percent*(p2R21-p1R21),p1R22+percent*(p2R22-p1R22))
end
while wait(1) do
local mod2 = mod:GetChildren()[math.random(1,#mod:GetChildren())]
if mod2 then
local light = mod2.Light
if light then
local movement = light.Movement
if movement then
local lightp = ((movement.Parent).LightPart)
local old_rot = old_rots[movement.Name]
local new_rot = pos[math.random(1,#pos)]
for i = 1,50,1 do
movement.CFrame = clerp(movement.CFrame,
old_rot
*CFrame.Angles(new_rot, 0, 0)
,.1)
lightp.CFrame = movement.CFrame*CFrame.new(0,1.2,0)
run.Heartbeat:wait()
end
else
print'3'
end
else
print'2'
end
else
print'1'
end
end
