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

Client/Server side problems?

Okay so basically, i have a nametag which shows a player name and level. I have this to update every couple' seconds and works perfectly. However, i wanted to enable filtering, so i wanted to work around the local script problem. It works, however you cannot see the other player's nametag, only your own tag which is weird.

Here is the server side script:

game.Players.PlayerAdded:connect(function(player)
	player:WaitForChild("Backpack")
	local event = Instance.new("RemoteEvent")
	event.Parent = player.PlayerGui
	event.Name = "LvlHeadEvent"
	
	local function Fire()
		event:FireClient(player)
		print("event sent")
	end
	
	while wait(1.5) do
		Fire()
	end
	
end)

Here is the Nametage Billboard GUI (client side, local script)

local player = script.Parent.Parent
function onPlayerUpdate()
	wait(0.1)
        if (player.Character:FindFirstChild('FakeHead')~=nil) then
        	if (player.Character.Head:FindFirstChild("BillboardGui")==nil) then
  			local gui=Instance.new("BillboardGui")
       	 	gui.Parent=player.Character.Head
        	gui.Adornee=player.Character.Head
        	gui.Size=UDim2.new(20,0,1,0)
        	gui.StudsOffset=Vector3.new(0,2,0)
      		local text1=Instance.new("TextLabel")
        	text1.Text = ("Loading")
        	text1.FontSize = "Size8"
			text1.TextColor3 = Color3.new(255,255, 255)
        	text1.TextStrokeColor3 = Color3.new(0, 0, 0)
			text1.TextScaled = true
        	text1.TextStrokeTransparency = 0
        	text1.Size=UDim2.new(1,0,1,0)
        	text1.Position=UDim2.new(0,0,-0.5,0)
        	text1.BackgroundTransparency = 1
        	text1.Parent=gui 
				else
        	player.Character.Head.BillboardGui.TextLabel.Text= (player.Name..", Level: "..player.leaderstats.Lvl.Value)
      	end 
	end 
end

local event = script.Parent:WaitForChild("LvlHeadEvent")
 
event.OnClientEvent:connect(function()
	onPlayerUpdate()
end)

thanks for any help if youre good with this stuff haha, ~bubs

1 comment

0

Edited my answer. As far as I could tell there's no need for RemoteEvents.

1 answer

✓ Accepted answer

I am sick and too lazy to explain

game.Players.PlayerAdded:connect(function(player)
	while wait(60) do
		for _, v in pairs (game.Players:GetPlayers()) do
			-- Make the gui, same as in the local I assume but change 'player' to v
		end
	end
end)

EDIT: I'm feeling a bit better, I'll try to rework the script.

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		if (character:FindFirstChild('FakeHead') ~= nil) and (character.Head:FindFirstChild("BillboardGui") == nil) then
			local gui = Instance.new("BillboardGui")
			gui.Parent = player.Character.Head
			gui.Adornee = player.Character.Head
			gui.Size=UDim2.new(20, 0, 1, 0)
			gui.StudsOffset=Vector3.new(0, 2, 0)

			local text1 = Instance.new("TextLabel")
			text1.Text = ("Loading")
			text1.FontSize = "Size8"
			text1.TextColor3 = Color3.new(255, 255, 255)
			text1.TextStrokeColor3 = Color3.new(0, 0, 0)
			text1.TextScaled = true
			text1.TextStrokeTransparency = 0
			text1.Size=UDim2.new(1,0,1,0)
			text1.Position=UDim2.new(0, 0, -0.5, 0)
			text1.BackgroundTransparency = 1
			text1.Parent=gui
				
			wait(1.5) -- Should give the same effect as that while loop.
				
			text1.Text= (player.Name..", Level: "..player.leaderstats.Lvl.Value)
		end 
	end)
end)

Tested, and it worked for me with FilteringEnabled. Hope this helped.

6 comments

0

alright ill see if i can implement this ha

0

If it doesn't work, go for the solution of adding another event sent back to the server to create it

0

this doesnt work btw, where did you want me to add it?

0

In the loop, in a server script.

0

thanks it worked :)

0

No problem.

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