I want to position circular frames on a map to represent other players, and render them based on player position, orientation, etc.
It is unfortunately behaving very weirdly (see in the video below), and I can’t seem to get it to work, any ideas?
robloxapp-20221229-0116120.wmv (1.2 MB)
self:Init("InitExtPlayer",function(plr)
if self["Players"][plr.UserId] then return end
local ExtIndicator = self["AppFrame"]["ExtIndicator"]:Clone()
ExtIndicator.BackgroundColor3 = GetNameColor(plr.Name)
ExtIndicator.PFP.UIStroke.Color = GetNameColor(plr.Name)
ExtIndicator.PFP.Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..plr.UserId.."&width=420&height=420&format=png"
ExtIndicator.Name = "_"..plr.UserId
ExtIndicator.MouseEnter:Connect(function()
ExtIndicator.PFP.Visible = true
end)
ExtIndicator.MouseLeave:Connect(function()
ExtIndicator.PFP.Visible = false
end)
game:GetService("RunService"):BindToRenderStep("_"..plr.UserId, Enum.RenderPriority.Last.Value, function()
if plr and plr.Character and plr.Character.HumanoidRootPart then
local Offset = self["ViewportCamera"].CFrame:PointToObjectSpace(plr.Character.HumanoidRootPart.Position)
local WorldSpace = self["ViewportCamera"].CFrame:PointToWorldSpace(Offset)
local vector, onScreen = self["ViewportCamera"]:WorldToViewportPoint(WorldSpace)--plr.Character.HumanoidRootPart.Position)
if onScreen then
ExtIndicator.Position = UDim2.fromScale(vector.X, vector.Y) --https://devforum.roblox.com/t/worldtoviewportpoint-with-a-viewportframe-and-a-camera-inside/1537775/2
ExtIndicator.Visible = true
end
end
end)
self["Players"][plr.UserId] = true
ExtIndicator.Parent = self["AppFrame"]
end)