I don't know what is wrong with this code

Hey guys,

I would like a little marker to float over a player’s head that is the same color as their team.

If the player is on the red team, this little dot will be red, and visible that way to any player regardless of the team.

this is the code i have so far, and how the objects are laid out.

I have no idea where to go next.


image

2 Likes

Hey, I have seen you have posted lots of questions for this type of script. Have you looked at any tutorials before.

And, if you want a dot to be over someone’s head, I recommend you get a billboard gui and clone it onto a player’s head.

2 Likes

yea, i was trying to figure that out in the script above.

1 Like
local ImageLabel = script.Parent.TeamMarkerLabel
ImageLabel.ImageColor3 = Players.TeamColor

Make the Team Marker Label into this: TeamMakerLabel.

I guess that is where the error is, you didn’t really make the local variable that well known.

Code:
local playermarkersort = script.Parent:Clone()

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local ImageLabel = script.Parent.TeamMarkerLabel
    ImageLabel.ImageColor3 = Players.TeamColor
end)
2 Likes

correction*

local ImageLabel = script.Parent.TeamMarkerLabel
ImageLabel.ImageColor3 = player.TeamColor

ok, so how do i clone this to the corresponding players head?

1 Like
local ImageLabel = script.Parent.TeamMarkerLabel:Clone() -- this line
ImageLabel.Parent = player.Head -- and this line
ImageLabel.ImageColor3 = player.TeamColor
2 Likes

local ImageLabel = script.Parent.TeamMarker:Clone()
ImageLabel.ImageColor3 = player.TeamColor

Just saw da guy above me lol.

2 Likes

When you clone something you have to tell it where to go (i’m not sure on this i just still like setting the parent)

Yeah, I was gonna fix that then I saw your reply and didn’t bother.

1 Like

@loueque @gxxrde @daslick

ok, so this is what we’ve got so far.

local playermarkersort = script.Parent("Team Marker"):Clone()
		
local Players = game:GetService("Players")
 
Players.PlayerAdded:Connect(function(player)
	local ImageLabel = script.Parent.TeamMarkerLabel:Clone() -- this line
ImageLabel.Parent = player.Head -- and this line
ImageLabel.ImageColor3 = player.TeamColor
end)

is this correct?

1 Like

Wait,

local playermarkersort = script.Parent("Team Marker"):Clone()
		
local Players = game:GetService("Players")
 
Players.PlayerAdded:Connect(function(player)
local ImageLabel = playermarkersort["Team Marker Label"]
playermarkersort .Parent = player.Head -- and this line
ImageLabel.ImageColor3 = player.TeamColor
end)

didn’t work.

I’ve got the billboard gui in rep storage, and the local script in it along with the image label. will that work properly?

You seem to be defining a variable, but you don’t have an equal sign and you have a space in the variable, try doing local imageLabel = script.Parent["Team Marker Label"]:Clone() imageLabel.ImageColor3 = Color3.new(player.TeamColor) imageLabel.Parent = player.Character.Head. For this to work though, you need to make this script a regular script and not a local script, otherwise other players wont be able to see the dot due to filtering enabled, you can learn more about this here Filtering Enabled Explanation this should also go into ServerScriptService. Also it doesn’t seem like you are too familiar with scripting, maybe try watching some tutorials.

I just updated it, try it now.

also, I just noticed. Try making this a server script and put it into ServerScriptService.

that didn’t work, either.

is it the settings of the image label and the billboard gui itself, then?

also i did change from local script to server script.

Have you tried to make it appear on the player in studio? (manually)

mhm.

bruhhhhhhhhhhhhhhhhhhhhhhh

Hit a few basic tutorials then come back, everything will make sense.

Lol I typed my reply then laptop died. The reason it won’t work is because you don’t have the character parameter defined. I’ll give you a script I edited.

local playerbill = game.ReplicatedStorage:WaitForChild("YourGUI"):Clone()
    game.Players.PlayerAdded:Connect(function(plr)
    	plr.CharacterAdded:Connect(function(char)
    		local playertag = playerbill:Clone()
    		playertag:WaitForChild('playernamelbl').Text = plr.Name -- just change this line to the image and do WaitForChild("ImageLabel").ImageColor3 = plr.TeamColor
    		playertag.Parent = game.Workspace:WaitForChild(plr.Name).Head
    	end)
    end)

If it didn’t work, feel free to inform me.