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

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

Asked by
GShocked 150
9 years ago

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
0
remove the '+ vector3.new' part. It seems to have an offset made by your code TheDeadlyPanther 2460 — 9y
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) GShocked 150 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
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.--]]


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. GShocked 150 — 9y
Ad
Log in to vote
0
Answered by
GShocked 150
9 years ago
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.

Answer this question