I have a big light beam I want at the same position as this cube at all times. Well the Cube teleports so I need the light beam to move with it. The beam is at the cubes position but when the cube moves the beam does not and it stays at the old spot. Any help here?
local beam= script.Parent local map = game.Workspace:WaitForChild("Map") local cube = map:WaitForChild("Cube") local cpos = cube.Position while true do wait() beam.CFrame = CFrame.new(cpos) end
local beam = script.Parent local map = game.Workspace:WaitForChild("Map") local cube = map:WaitForChild("Cube") local cpos = cube.Position while true do wait() beam.CFrame = CFrame.new(cpos) --the problem is here end
Since you are setting the beams CFrame to cpos (which is defined only once), you are forever setting it to the same coordinate. Instead, set it to the cube's CFrame, like so:
local beam= script.Parent local map = game.Workspace:WaitForChild("Map") local cube = map:WaitForChild("Cube") while true do wait() beam.CFrame = cube.CFrame --Every part has a CFrame property you can read, as well as write end