local Client=game:GetService('Players').LocalPlayer
local Part=workspace:WaitForChild('Part')
local HumanoidRP=Client.Character:WaitForChild('HumanoidRootPart')
local Camera=workspace.CurrentCamera
while wait() do
local Facing=HumanoidRP.CFrame.LookVector
local Vector=(HumanoidRP.Position-Part.Position).unit
local MathVariable=math.deg(math.acos(Facing:Dot(Vector)))
script.Parent.Rotation=MathVariable
end
This line needs a vector3 not a single number, (I think).
Could you elaborate on the problem?
@Ashp116 i have a gui image that i need to display the position of an attacker (brick in images) relative to local character’s position while considering local camera orientation (or humanoid root part cframe doesnt matter bc its first person)
try this
local Client=game:GetService('Players').LocalPlayer
local HumanoidRP=Client.Character:WaitForChild('HumanoidRootPart')
while wait() do
local Part=workspace:WaitForChild('Part')
local Camera=workspace.CurrentCamera
local Facing=HumanoidRP.CFrame.LookVector
local Vector=(HumanoidRP.Position-Part.Position).unit
local MathVariable=math.deg(math.acos(Facing:Dot(Vector)))
script.Parent.Rotation=MathVariable
end
that gives me the same problem
The issue is because of how Dot Product works. The value it returns is a comparison between two Unit Vectors. Which means that it returns the same value no matter if the part is more to the right or the left.
So, I don’t think you could get away with just using Dot Product to create a damage indicator. You would need to find way to reverse the sign of the number based off if the source of damage is on the left or right side of the player’s Unit Vector.
local Client=game:GetService('Players').LocalPlayer
local Part=workspace:WaitForChild('Part')
local HumanoidRP=Client.Character:WaitForChild('HumanoidRootPart')
local Camera=workspace.CurrentCamera
while wait() do
local Facing=HumanoidRP.CFrame.LookVector
local Vector=(HumanoidRP.Position-Part.Position).unit
local MathVariable=math.deg(math.acos(Facing:Dot(Vector)))
script.Parent.Rotation=-MathVariable*math.sign(Facing:Cross(Vector).Y)
end