for some reason the hinge wont go past 90 degrees. I don’t know how to fix it. It is probably with the mouse and not the hinge.
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
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.Position.X,RootPart.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 ratio = (XZpos.Y-HKpos.Y)/(XZpos.X-HKpos.X)
local beta = math.atan(ratio) -- 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)
--on the client it is sending the mouse.hit.position
(THIS IS NOT MY MODEL)
i modified it to point where the mouse is and not where the payer is. here is the model if you want it:
https://web.roblox.com/library/4506974149/Servo-that-points-at-you