When looking at other people my radar thinks hes behind me, ive been trying to solve this issue for an hour but cant get it to work.
Here is my script:
--// Settings
local Settings = {
Scale = 1,
LocalColor = Color3.fromRGB(16, 236, 255),
EnemyColor = Color3.fromRGB(254, 0, 107),
Teamcheck = false
}
--// Variables
local players = game:GetService('Players')
local lp = players.LocalPlayer
local camera = workspace.CurrentCamera
--// Services
local uis = game:GetService('UserInputService')
local rs = game:GetService('RunService')
--// Relative
function getRelative(pos)
local char = lp.Character
if char ~= nil and char.PrimaryPart ~= nil then
local pmpart = char.PrimaryPart
local camerapos = Vector3.new(camera.CFrame.Position.X, pmpart.Position.Y, camera.CFrame.Position.Z)
local newcf = CFrame.new(pmpart.Position, camerapos)
local r = newcf:PointToObjectSpace(pos)
return r.X, r.Z
else
return 0, 0
end
end
--// Base function
function addEnemy(player)
local dot = script.Parent.You:Clone()
dot.Parent = script.Parent
dot.Visible = true
local r
r = rs.RenderStepped:Connect(function()
if player then
if player.Character and player.Character.PrimaryPart and lp.Character and lp.Character.PrimaryPart then
local relx, rely = getRelative(player.Character.PrimaryPart.Position)
local offset = Vector2.new(relx * Settings.Scale, rely * Settings.Scale)
local distance = 1/200
offset = offset * distance
dot.Position = UDim2.new(math.clamp(offset.X + 0.5,0,1), 0,math.clamp(offset.Y + 0.5,0,1),0)
end
else
dot:Destroy()
r:Disconnect()
end
end)
end
--// Adding enemies
for _, player in pairs(players:GetPlayers()) do
addEnemy(player)
end
players.PlayerAdded:Connect(function(player)
addEnemy(player)
end)