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

why cant I make a part point to another specific part?

Asked by 5 years ago

I got this script on a brick (part1) for pointing another brick(part2)

part1 = script.Parent.parent.part1
part2 = script.Parent.parent.part2
CFrame.new(part1.Position,part2.Position) 

and in the workspace i got two normal bricks called part1 and part2 with anchor and collisions on.

I preferred to use relative object selection because then i can store the parts where I want when I fix the problem.

the script would be theorically correct but when i start the game it doesnt change the orientation

1 answer

Log in to vote
1
Answered by 5 years ago

Revised

local part1 = script.Parent.Parent.part1
local part2 = script.Parent.Parent.part2
part1.CFrame = CFrame.new(part1.Position, part2.Position)

Firstly, you need to capitalize all the parents when defining the variables, since Parent is a property of the parts

Secondly, you can't just define a new CFrame and expect something to happen, since the game doesn't know what part's CFrame is supposed to be changed (in the example above, the part1 CFrame is altered)

0
is roblox case sensitive? luiskawaiineko -18 — 5y
0
When defining specific locations of parts and properties, yes, you need to be exact in your wording, or else it will not work correctly (potentially returning "nil") SerpentineKing 3885 — 5y
0
ROBLOX Lua is very case sensitive, if you make a mistake with capitalization then it will error no matter what. 3ora 54 — 5y
Ad

Answer this question