self-explanatory, I don’t exactly know what is happening with it.
code:
-- Wait for player to join game
repeat wait() until #game.Players:GetChildren() > 0
Player = game.Players:GetChildren()[1]
-- Wait for Player's character to load
if not Player.Character then
Player.CharacterAdded:Wait()
end
-- define some variables
Char = Player.Character
--CharPart = workspace.Bases.Team1:WaitForChild("GSOoneblock")--Char:WaitForChild('HumanoidRootPart')
Hinge = script.Parent
RootPart = Hinge.Parent
event = game:GetService("ReplicatedStorage").Events.GEEE
event.OnServerEvent:Connect(function(plr,lr)
-- define position of origin
local HKpos = Vector2.new(RootPart.CFrame.Position.X,RootPart.CFrame.Position.Z)
-- define position of target
local XZpos = Vector2.new(lr.Position.X,lr.Position.Z)
-- the ratio to get the triangle's width over the height
local beta = math.atan2(XZpos.Y-HKpos.Y,XZpos.X-HKpos.X) -- converting this to radians
-- turn it from radians into degrees
beta = beta*(180/math.pi)
print(beta)
Hinge.TargetAngle = beta -- beta has to be negative so it points at you
end)