Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I locate all my team members?

What I am trying to do is something like a lot of games have where a blue dot is always above your team's heads, but I can't get it quite right.
What I have thought about:

-- in a localscript in the player

for i, obj in pairs(player.team:GetPlayers()) do
    
      P =  obj.Character.Head.CFrame
    	Locate = instance.new("Part")
	Locate.Parent = workspace
	Locate.Anchored = true
	Locate.Scale = Vector3.new(3,3,3)
	Locate.Color = Color3.new(0,0,1)
	Locate.CFrame = P
	--and so on
end

(I have not tried this script yet but I don't think it would do what I want) This might work, but I need to be able to see the dots through walls, and in other games it almost seems like they use GUIs and somehow position them on their teammates. Is this really what they do? And if so how would I go about it?

PS. I am not asking for you to write a script, just give me a few pointers in the right direction.

Thanks

1 comment

0

Lua is case sensitive, so Instance.new(), player.Team, etc should be used. As for the question, I would unanchor the part and instead use a weld connected to the HumanoidRootPart instead. From there insert a BillboardGui -> ImgLabel into the part and set AlwaysOnTop to true.

1 answer

✓ Accepted answer

Local Script

local player = game.Players.LocalPlayer
local Teams = game:GetService("Teams")

wait(5) -- You can change this to be a Function if Needed
for a, b in pairs(Teams:GetTeams()) do
	if b == player.Team then
		for i, obj in pairs(b:GetPlayers()) do
			local character = workspace:FindFirstChild(obj.Name)
			
			local Locate = Instance.new("Part")
			Locate.Name = "Locator"
			Locate.Parent = character
			Locate.Anchored = false
			Locate.CanCollide = false
			Locate.Size = Vector3.new(3, 3, 3)
			Locate.Transparency = 1
			Locate.CFrame = character.Head.CFrame
			
			local Weld = Instance.new("Weld")
			Weld.Parent = Locate
			Weld.Part0 = Locate
			Weld.Part1 = character:WaitForChild("Head")
			Weld.C0 = CFrame.new(0, -3, 0)
			
			local Billboard = Instance.new("BillboardGui")
			Billboard.Name = "DisplayDot"
			Billboard.Parent = Locate
			Billboard.AlwaysOnTop = true
			Billboard.Adornee = Locate
			Billboard.Size = UDim2.new(1, 0, 1, 0)
			--Billboard.MaxDistance = math.huge
			
			local ImageLabel = Instance.new("ImageLabel")
			ImageLabel.Name = "Dot"
			ImageLabel.Parent = Billboard
			ImageLabel.Size = UDim2.new(1, 0, 1, 0)
			ImageLabel.ImageColor3 = Color3.fromRGB(0, 0, 255)
			ImageLabel.Image = "rbxassetid://1435770904"
			ImageLabel.BackgroundTransparency = 1
			
			wait()
		end
	end
wait()
end

PREVIOUS ERRORS: The errors you had were related to case sensitive material

"player.team" should be "player.Team"

"instance.new()" should be "Instance.new()"

Scale is not a valid Property of a Part, but Size is

EXPLANATION OF VARIABLES

Teams:GetTeams() is used to get the teams from the game in a table (the for loop iterates over these)

When the Team matches the player's team, a second table Team:GetPlayers()is used to get all players on that team

Welds make sure the parts in the Part1 and Part0 Properties are connected and stay at an offset set by the C0 Property.

The BillboardGui will make the ImageLabel Circle appear above a player's head (the offset of this is taken from the Adornee Property, as the Locate is welded to the player's Head)

3 comments

0

So always on top is what I need to show it through walls? Thanks!

0

also thanks for writing the script that would have taken me an hour or so :D

0

Well technically to make sure its always visible you can use the "max distance" property, however since this is automatically set to infinity, you don't need to set it

This discussion is preserved as it was. New answers, comments, and votes are closed.