Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Client/Server side problems?

Asked by 8 years ago

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

0
Edited my answer. As far as I could tell there's no need for RemoteEvents. Pyrondon 2089 — 8y

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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.

0
alright ill see if i can implement this ha Bubbles5610 217 — 8y
0
If it doesn't work, go for the solution of adding another event sent back to the server to create it Pyrondon 2089 — 8y
0
this doesnt work btw, where did you want me to add it? Bubbles5610 217 — 8y
0
In the loop, in a server script. Pyrondon 2089 — 8y
View all comments (2 more)
0
thanks it worked :) Bubbles5610 217 — 8y
0
No problem. Pyrondon 2089 — 8y
Ad

Answer this question