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

How should I float a brick in front of the player's Camera?

I know this isn't right, but its what I have so far. The results are not exactly what I am looking for.

I want it to be a floating brick in front of my camera, but here is what I get: https://gyazo.com/37997b21badfe7610026fad91e69d4a7

wait(2)
local part = Instance.new("Part",game.Workspace.Camera)
part.Anchored = true
while true do
	part.CFrame = game.Workspace.Camera.CoordinateFrame + Vector3.new(0, 0, -15)
	wait(0.001)
end

2 comments

0

remove the '+ vector3.new' part. It seems to have an offset made by your code

0

@TheDeadlyPanther Removing that places the brick at the exact location of the Camera. It also turns the brick, but I want the brick to face the Camera (not face the same way the camera is facing)

2 answers

function Rotate()
      local plr = game.Players.LocalPlayer;
      local char = plr.Character
     local position = char.Torso
     Distance = 4
     part.CFrame = position.CFrame*CFrame.new(0,0, Distance) -- or 0,0,4
     pcall(function() part.CFrame = position.CFrame*CFrame.new(0,0,Distance) end) --This line of code is so when the part spawns, its auto CFramed to the players Torso.
end

game:GetService("RunService").Stepped:connect(Rotate) 

**THIS MUST BE A LOCALSCRIPT **

--If you wanna make it a full 360 degrees around the torso then:
**MUST ALSO BE A LOCALSCRIPT**


while wait() do
      for i = 0,360 do
               local plr = game.Players.LocalPlayer; 
               local char = plr.Character
               local position = char.Torso
               Distance = 4
              wait()
              part.CFrame = position.CFrame*CFrame.Angles(0,math.rad(i),0)*CFrame.new(0,0, Distance)
       end
end

--[[No function on this one. So it wont be as smooth.--]]


1 comment

0

This isn't exactly what I had in mind. I was looking for a script to position a brick in front of the camera, not the character. I'm not looking to make admin tabs or anything; I'm trying to make a stylish GUI system that uses floating bricks with surfaceguis.

wait(2)
local part = Instance.new("Part",game.Workspace.Camera)
part.Anchored = true
part.CanCollide = false

while wait() do
	part.CFrame = game.Workspace.Camera.CoordinateFrame * CFrame.new(5, 0, -10)
end

This worked, thanks to SenseiWarrior.

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