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!
What is the issue? I have a bar in my game and want to increase/decrease the size of the bar depending if the player is looking up or down
What solutions have you tried so far? I’ve searched endlessly but could not find anything
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
1. Take the dot product of up vector and camera look vector. 2. Clamp it in range [0; 1]. 3. Lastly apply this number to the absolute Y size.
local background_bar -- black one
local main_bar -- blue one
local d : number = Vector3.new(0, 1, 0):Dot(Camera.LookVector);
local a : number = (d + 1) * .5;
local y_size : number = (a * background_bar.AbsoluteSize.Y) / background_bar.AbsoluteSize.Y;
main_bar.Size = UDim2.fromScale(1, 0, y_size, 0);
local player = game.Players.LocalPlayer
local char = player:FindFirstChild("Character")
local hrp = char:WaitForChild("HumanoidRootPart")
local runService = game:GetService("RunService")
local cam = workspace.CurrentCamera
runService.RenderStepped:Connect(function()
local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
print(camDirection)
end)