Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dx,dy
- local angle=0
- local next=next
- local pcall=pcall
- local atan2=math.atan2
- local abs=math.abs
- local part=game.Workspace.Part
- local part2=game.Workspace.Part2
- local x1,y1,z1,R00,R01,R02,R10,R11,R12,R20,R21,R22=part.CFrame:components()
- local r1,r2,r3=part.Rotation.X,part.Rotation.Y,part.Rotation.Z
- local n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- local function changed(part)
- local amt1,amt2,amt3,amt4,amt5,amt6,amt7,amt8,amt9,amt10,amt11,amt12,amt13,amt14,amt15=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- local x2,y2,z2,R001,R011,R021,R101,R111,R121,R201,R211,R221=part.CFrame:components()
- local r11,r21,r31=part.Rotation.X,part.Rotation.Y,part.Rotation.Z
- if x2~=x1 or y2~=y1 or z2~=z1 or R001~=R00 or R011~=R01 or R021~=R02 or R101~=R10 or R111~=R11 or R121~=R12 or R201~=R20 or R211~= R21 or R221~= R22 or r11~=r1 or r21~=r2 or r31~=r3 then
- amt1=x2-x1
- amt2=y2-y1
- amt3=z2-z1
- amt4=R001-R00
- amt5=R011-R01
- amt6=R021-R02
- amt7=R101-R10
- amt8=R111-R11
- amt9=R121-R12
- amt10=R201-R20
- amt11=R211-R21
- amt12=R221-R22
- amt13=r11-r1
- amt14=r21-r2
- amt15=r31-r3
- x1,y1,z1,
- R00,R01,R02,
- R10,R11,R12,
- R20,R21,R22,
- n1,n2,n3,
- n4,n5,n6,
- n7,n8,n9,
- n10,n11,n12,
- n13,n14,n15=x2,y2,z2,
- R001,R011,R021,
- R101,R111,R121,
- R201,R211,R221,
- amt1,amt2,amt3,
- amt4,amt5,amt6,
- amt7,amt8,amt9,
- amt10,amt11,amt12,
- amt13,amt14,amt15
- return amt1,amt2,amt3,amt4,amt5,amt6,amt7,amt8,amt9,amt10,amt11,amt12,amt13,amt14,amt15
- end
- --[[if x2~=x1 then
- if y2~=y1 then
- if z2~=z1 then
- amt1=x2-x1
- amt2=y2-y1
- amt3=z2-z1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- else
- amt1=x2-x1
- amt2=y2-y1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- end
- elseif z2~=z1 then
- amt1=x2-x1
- amt3=z2-z1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- end
- elseif y2~=y1 then
- if z2~=z1 then
- amt2=y2-y1
- amt3=z2-z1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- else
- amt2=y2-y1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- end
- elseif z2~=z1 then
- amt3=z2-z1
- x1,y1,z1,n1,n2,n3=x2,y2,z2,amt1,amt2,amt3
- return amt1,amt2,amt3
- end]]
- end
- local function rot()
- if part and part2 then
- local dx=(part.CFrame.X-part2.CFrame.X)
- local dy=0
- local dz=(part.CFrame.Z-part2.CFrame.Z)
- local angle=atan2(dz,dx)
- if angle<0 and angle>-3.14 then
- print("Part can still see Part 2")
- else
- print("Part cannot see Part 2")
- end
- end
- end
- local function rot2()
- if changed(part) then
- local x,y,z,R00,R01,R02,R10,R11,R12,R20,R21,R22=part2.CFrame:components()
- local r1,r2,r3=part2.Rotation.X,part2.Rotation.Y,part2.Rotation.Z
- part2.CFrame=CFrame.new(x+n1,y+n2,z+n3,R00+n4,R01+n5,R02+n6,R10+n7,R11+n8,R12+n9,R20+n10,R21+n11,R22+n12)
- --part2.Rotation=Vector3.new(r1+n13,r2+n14,r3+n15)
- end
- end
- print("hi")
- game:service'RunService'.Stepped:connect(function() rot2() end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement