You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make this part’s orientation be exactly flat on the players camera so it looks like the player is looking into an ipad.
Heres what it looks like:
The ipad is sideways and i tried forcing to to go flat in my script.
What is the issue? Include screenshots / videos if possible!
Idk why it wont work.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried YT and DevForum
My Code
local Camera = game.Workspace.CurrentCamera
local Monitor = game.ReplicatedStorage:WaitForChild("Monitor"):Clone()
Monitor.Parent = Camera
RunService.RenderStepped:Connect(function()
if Player.Character.Humanoid.Health == 0 then
if Camera:FindFirstChild("Monitor") ~= nil then
Camera.Monitor:Destroy()
end
end
if Camera:FindFirstChild("Monitor") ~= nil then
Monitor.Orientation = Vector3.new(0,90,0)
Monitor.CFrame = Camera.CFrame * CFrame.new(0, 0.7, -2)
end
end)
you need to set the orientation before cloning it would be so much better
local lp = game:GetService("Players").LocalPlayer
local Monitor = game:GetService("ReplicatedStorage"):WaitForChild("Monitor"):Clone() --Just edit the monitor's orientation before cloneing
local Camera = workspace.CurrentCamera
Monitor.Parent = Camera
game:GetService("RunService").RenderStepped:Connect(function()
local char = lp.Character
local Humanoid = char and char:FindFirstChildWhichIsA("Humanoid")
if Monitor:IsDescendantOf(Camera) and Humanoid and Humanoid.Health > 0 then
Monitor.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0,0,-2)
else
Monitor:Destroy()
end
end)
You can either use CFrame.Angles or resize the part to make it correctly angled.
To Resize, just use the front face and size it correctly with the front face as the rear of the tablet.
Keep in mind CFrame uses radians not degrees.
Test with different values in each of the 3 params, your use case may be different than this example.
^^^ Setting the orientation before cloning does nothing useful in this script. Setting the CFrame to the camera’s + offset will reset the orientation to the camera’s.