So I’m working on a flight-game and I want to make some markers that should point in the direction of where the player is. Something like those red markers on the right side.
I’m not entirely sure how your game’s code would look like but if I was approaching this id do something like this:
local PlayersInMatch = game.ReplicatedStorage.Game.PlayersInMatch-- We set this value to 10 for an example
local Blue= game.ReplicatedStorage.Game.BluePlayers-- We set this value to 10 for an example
local Red= game.ReplicatedStorage.Game.RedPlayers-- We set this value to 10 for an example
local tag = game.ReplicatedStorage.Tag -- The surfaceGUI tags
--Lets for example say following code activates when 3 players remain and you subtract 1 for every dead player for each team NumValue.
game.Players.PlayerAdded:Connection(function(plr) --Player joins the server
PlayersInMatch.Changed:Connect(function() --Players in match increases/decreases like on every respawn
--When ever a player dies we would remove a 1 from the players we identified already this is for
--detecting amount of players left
if Red.Value == 3 then --Can be removed if you want markers at all times
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Really red") then
local KillTag = tag:Clone()
Killtag.Parent = game.workspace[v.Name].Head --Doesn't have to be a character
end
end
if Red.Value == 3 then --Can be removed if you want markers at all times
for i,v in pairs(game.Players:GetChildren()) do
if v.TeamColor == BrickColor.new("Really blue") then
local KillTag = tag:Clone()
Killtag.Parent = game.workspace[v.Name].Head --Doesn't have to be a character
end
end
end
--Following code would be used for math type like FFA
else
if PlayersInMatch == 3 then
for i,v in pairs(game.Players:GetChildren()) do
if game.Workspace:FindFirstChild(v.Name) then --If we have a GUI lobby then our charaacter doesn't exist to prevent killtags on nothing
local KillTag = tag:Clone()
Killtag.Parent = game.workspace[v.Name].Head --Doesn't have to be a character
end
end
end
end
end)
end)
Players in match yes is a intvalue and killtag is a surface gui that is already created and stored somewhere so then we don’t have to create 1 each time