Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

3 comments

0

is roblox case sensitive?

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")

0

ROBLOX Lua is very case sensitive, if you make a mistake with capitalization then it will error no matter what.

This discussion is preserved as it was. New answers, comments, and votes are closed.