New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
0

# Why does my part go to nowher near my camera?

Hi (again)! I am trying to make a part follow where my camera is (if you don't know yet). It doesn't go anywhere near the camera and goes in one certain spot. Help! (there is no error)

local owner = game.Players.iiDkOffical
local group = Instance.new("Model")
group.Name = "Unknown"
group.Parent = game:GetService("Workspace")
local humanoid = Instance.new("Humanoid")
humanoid.Parent = group
while true do
wait(0.25)
group.Name = owner.Name.." - Camera"
end


1
Feahren 3677
14 days ago
Edited 14 days ago

CurrentCamera is the actual Camera that is adjusted on the Player's screen, referencing 'Camera' will be setting the CFrame to a static position. Since the Camera is also rendered every Frame, we can tell the Part to match it's position at the same rate with RunService's .Heartbeat signal. This way we can make it follow the Camera smoothly.

local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function()
end)

0
nope, still doesn't follow the camera iiDkOffical 73 — 14d
0
Ensure this is a LocalScript, as I said before. Feahren 3677 — 14d
0
can you make it a script? iiDkOffical 73 — 14d
0
You'll still need a LocalScript to have this properly work. Use a RemoteFunction to call upon the Players Camera CFrame through the LocalScript, then the ServerScript to adjust the Part. Feahren 3677 — 14d
0
i knew that would be the answer iiDkOffical 73 — 14d
0
I tested my code above, conjoined with yours, it works perfectly fine, but I'm not necessarily sure why you want this to happen? It will constantly be interrupting the Camera's FOV causing it to push forward. If you want something to float above the Characters head? Then you can simply weld a part to it. Feahren 3677 — 14d
1
Nanomatics 1107
14 days ago
Edited 14 days ago

Just made the script a bit neater, this should work

--- put this in a localscript under StartPlayerScripts which is under StarterPlayer
local camera = workspace.CurrentCamera
local part

wait(3) -- just to make sure everything loaded

game["Run Service"].Heartbeat:Connect(function()
if not part then
local player = game.Players.LocalPlayer
local char = player.Character
part = Instance.new("Part")
part.Name = "CAMERAPART"
part.Anchored = true
part.Parent = char
part.CFrame = camera.CFrame
end
part.CFrame = camera.CFrame
end)


Hope I helped, if you have any questions please let me know