#Ive had the problem for absolutely ages - rng game and the name tag isnt appearing above the player

1 messages · Page 1 of 1 (latest)

frigid wraith
#

ive got no idea how to fix haha

lunar elm
#

elaborate

frigid wraith
#

huddon im getting the code

#

very large 😦

#

right thats the main script

#
local event = game.ReplicatedStorage.NameTagEvent
local players = game.Players

event.OnServerEvent:Connect(function(player)
    local rarityLabel = player.PlayerGui.ScreenGui:WaitForChild("RarityLabel")
    local character = player.Character or player.CharacterAdded:Wait()
    print("nametag blah")
    local Tag = nameTag:Clone()
    Tag.RarityName.Text = rarityLabel.Text
    Tag.Parent = character.Head
end)```
#
local player = game.Players.LocalPlayer
local equipButton = player.PlayerGui.ScreenGui.equipButton

equipButton.MouseButton1Click:Connect(function()
    event:FireServer()
    print("event fired")
end)```
#

very messy ik

lunar elm
#

peak code

frigid wraith
#

ikr

#

i left making this game for a while cuz literally no one knew what was wrong :/

#

ill send a vid

lunar elm
#

why are all the table items just bangers font

#

you kinda have to set the tags adornee

#

tag.adornee = character.head

frigid wraith
#

right what does that do

lunar elm
#

ok so

#

you have to set adornee

#

for it to appear

#

above your head

frigid wraith
#

what is adornee sry

lunar elm
#

property

#

of billboardgui

frigid wraith
#

right

#

ok

#

so where shall i put that then

frigid wraith
#

ok thanks

lunar elm
#

Tag.Adornee = character.Head

frigid wraith
#

or no

#

sry if its wrong

#

im thick as mince

#

does it go w the variables

lunar elm
#

put it below tag.rarityname.text

#

Tag.Adornee

#

not nameTag

frigid wraith
#

right

#

still nothing

spiral cove
#

Offset?

frigid wraith
frigid wraith
lunar elm
#

interesting

frigid wraith
#

very

lunar elm
#

is it printing anything

frigid wraith
#

yeah

lunar elm
#

ah i see what might be causing it

spiral cove
#

Wait

lunar elm
#

if the changes in playergui are made locally, the server can't see them

frigid wraith
lunar elm
#

therefore he doesn't know what raritylabel is

spiral cove
#

Do you even use billboardGUI?

frigid wraith
#

yea

lime trailBOT
#

studio** You are now Level 11! **studio

spiral cove
#

And a text label that is decendant of that?

lunar elm
frigid wraith
#

wait

#

idek if im using a billboard

lunar elm
#

check

frigid wraith
#

😭 😭 😭

spiral cove
#

Do you want the text label to appear above the player?

lime trailBOT
#

studio** You are now Level 7! **studio

lunar elm
frigid wraith
#

no 😦

lunar elm
#

then make it one

frigid wraith
#

alr

spiral cove
#

Because if thats the case your gonna have to rearrange everything

lunar elm
#

make one
set the size to something like 6, 0, 1.2, 0

frigid wraith
#

chuck it into starter gui?

lunar elm
#

preferably not

#

place it in a script in serverscriptservice

frigid wraith
#

wait

#

ive not worked on this in ages my god

spiral cove
frigid wraith
spiral cove
#

Hm

#

Let me get on my laptop

#

bro

frigid wraith
#

?

#

im thick

#

what is it

spiral cove
#
local event = game.ReplicatedStorage.NameTagEvent
local player = game.Players.LocalPlayer
local equipButton = player.PlayerGui.ScreenGui.equipButton

equipButton.MouseButton1Click:Connect(function()
    event:FireServer(equipButton.Text)
    print("event fired")
end)

local nameTag = script:WaitForChild("NameTag") -- Is this a billboardGUI?
local RS = game:GetService("ReplicatedService")
local event = RS:WaitForChild("NameTagEvent")
local players = game:GetService("Players")

event.OnServerEvent:Connect(function(player, RarityLabelText)
    local character = player.Character or player.CharacterAdded:Wait()
    print("nametag blah")
    if character:FindFirstChild("NameTag") then
        character:WaitForChild("NameTag"):Destroy()
    end
    local Tag = nameTag:Clone()
    Tag.RarityName.Text = RarityLabelText
    Tag.Parent = character.Head
end)
#

idk if this will work since i dont know how you arranged your things

#

but this could help you get on right track

frigid wraith
#

i think its smth to do w the main script

#

as there was already a billboard gui but only u could see and not other players but i made that transparent and tried to remake one

spiral cove
#

Was the billboard gui created with a localscript?

frigid wraith
#

ik whats up

#

so

#

it was a text label

#

when i remade it i put it in another place

#

i made this game like a month ago thats why ive forgotten everything

#

for some reason the roll gui isnt appearing now

spiral cove
#

idk what to say, good luck with cleaning everything

frigid wraith
#

thank u

#

hopefully this will work

#

im changing some things up

spiral cove
#

i think you know how to fix the issue, just make sure that all definitions in the scripts are correct, check the console for errors

frigid wraith
#

for some reason there is so many errors that werent happening b4

#

im so confused bro

spiral cove
#

screenshot?

frigid wraith
#

local rarityLabel = Instance.new("BillboardGui")
rarityLabel.Name = "RarityLabel"
rarityLabel.BackgroundTransparency = 1
rarityLabel.Size = UDim2.new(0, 400, 0, 200)
rarityLabel.Font = Enum.Font.FredokaOne
rarityLabel.Text = "What Country will you get?"
rarityLabel.TextSize = 50
rarityLabel.Position = UDim2.new(0.5, 0, 0.5, -400)
rarityLabel.AnchorPoint = Vector2.new(0.5, 0.5)
rarityLabel.Parent = game:GetService("Players").LocalPlayer.PlayerGui.ScreenGui

#

cant even

#

the scrips to big

#

this part btw

#

wait

spiral cove
#

nonono

#

billboardgui doesnt have label properties

#

make a textlabel with billboardgui as parent

#

just change instance.new to "TextLabel"

frigid wraith
#

its not even that part

#

wait

#

i think its there?

#

current rarity gui

spiral cove
#

why is textLabel visible false?

frigid wraith
#

text label should be a bill boar gui

#

should i make current rarity gui text label?

spiral cove
#

your making me confused fr

#

do you want to let everyone see the text?

#

or only the local player?

frigid wraith
#

im confused rn

spiral cove
#

then everything of that needs to be handled with a serverscript

frigid wraith
#

i think something is something when its another thing

spiral cove
#

localscript = client only
serverscript = Server = everyone can see

#

you need to communicate with the server from the client

frigid wraith
#

what should i do?

spiral cove
#

remoteevent

#

with arguments

frigid wraith
#

idek at this point

spiral cove
#
local player = Players.Localplayer
local Data = {
  currentRarityGui = currentRarityGui
  
}
event:FireServer(player, "EquipLabel", Data)
#

local function updateLabel(player, Data)
  local character = Workspace:WaitForChild(player.Name)
  print("nametag blah")
  -- create billboardGui or clone a template from ReplicatedService
  -- use Data.currentRarityGui to get the instance made from localscript

end

event.OnServerEvent:Connect(function(player, Arg, Data)
    if Arg == "EquipLabel" then
      updateLabel(player, Data)
    end
end)
#

see if you can use this

frigid wraith
#

ok ty ty

frigid wraith
spiral cove
#

yeah

frigid wraith
#

alr

spiral cove
#

But keep in mind that there are some flaws

frigid wraith
#

same for the first one as well

frigid wraith
spiral cove
#

Client should not be able to decide everything, makes it exposed to exploiters making false event executions

#

example being if the rolled item is decided by client and sent to the server as "ItemRewarded" = LegendaryItem then it can easily be abused by exploiters

frigid wraith
#

mm

spiral cove
#

Also if you are using a currency to roll items, make sure that the currency is handled on the server and that if the player sends a remote event, make sure they could afford it and that their currency was decreased = to the cost

#

if that makes sense

frigid wraith
#

what is replicated service?

spiral cove
#

example being:


local player = Players.Localplayer
local Data = {
  currentRarityGui = currentRarityGui,
  Rarity = "Legendary"
  
}
event:FireServer(player, "EquipLabel", Data)

local function updateLabel(player, Data)
  local character = Workspace:WaitForChild(player.Name)
  print("nametag blah")
  nametag.text = Data.Rarity
  -- create billboardGui or clone a template from ReplicatedService
  -- use Data.currentRarityGui to get the instance made from localscript

end

event.OnServerEvent:Connect(function(player, Arg, Data)
    if Arg == "EquipLabel" then
      updateLabel(player, Data)
    end
end)

since the rarity was decided by the localscript, it can be abused by exploiters

frigid wraith
#

ok

spiral cove
frigid wraith
#

how should i reference this

#

ahh ok

#

just checking incase

spiral cove
#

its an error since its not defined yet

frigid wraith
#

how would i define it

spiral cove
#

local currentRarityGui =

frigid wraith
#

would that not change the first bit

#

or am i stupid

spiral cove
#

you either make a template and put it in ReplicatedStorage and find it there

#

or create it in the localscript

#

like how you did it

#

do

#

local currentRarityGui = Instance.New("BillboardGui")
local textLabel = Instance.New("TextLabel")
textLabel.Parent = currentRarityGui
#

and in the serverscript do

frigid wraith
#

ok right

#

ty

spiral cove
#

Data.currentRarityGui.Parent = character.HumanoidRootPart

frigid wraith
#

im too confused tn lol

spiral cove
#

and change its offset to 4 on the Y axis

frigid wraith
#

that right?

spiral cove
#

oh my bad

#

its .new

#

not .New

#

and remove player.Character

#

since you defined the character

#

only do character.HumanoidRootPart

frigid wraith
spiral cove
#

yeah seems right

frigid wraith
#

dk wat that A is doing there

spiral cove
#

does it work?

frigid wraith
#

ill test

spiral cove
frigid wraith
#

no

#

at the end

spiral cove
#

oh

frigid wraith
#

what even is arg?

spiral cove
#

Argument

frigid wraith
#

ahh o

#

ok

#

cool

#

ty

#

still no 😦

spiral cove
#

I know why

frigid wraith
#

"equipbutton"?

#

i changed that

#

is it smth else?

spiral cove
#

try this instead


local player = Players.Localplayer
local Data = {}
event:FireServer(player, "EquipLabel", Data)

local function updateLabel(player, Data)
  local character = Workspace:WaitForChild(player.Name)
  print("nametag blah")
  local BillboardGui = Instance.new("BillboardGui")
  local textLabel = Instance.new("TextLabel")
  textLabel.Parent = BillboardGui
  BillboardGui = character.HumanoidRootPart
  -- create billboardGui or clone a template from ReplicatedService
 

end

event.OnServerEvent:Connect(function(player, Arg, Data)
    if Arg == "EquipLabel" then
      updateLabel(player, Data)
    end
end)

#

and if its on fresh scripts without the clickEvent just do wait(1) at the start of the local script to let the game load in

frigid wraith
#

do i put anything in data

spiral cove
#

no keep it empty

#

if you need to pass values or instances then use it

frigid wraith
#

alr

spiral cove
#

you could do Data = {
Arg = "EquipLabel
}

and in serverscript do

if Data.Arg == "EquipLabel" then

#

and remove Arg from the serverscript

#

and remove "EquipLabel" from the fireServer

#

Since Data is a table to pass multiple values

#

you dont really need to put a lot in arguments

frigid wraith
#

that all good?

spiral cove
#

Yeah

#

Nice

#

That should work

frigid wraith
#

alr

spiral cove
#

do wait(1)

#

at the start of local script

frigid wraith
spiral cove
#

and check console if it prints

#

LocalPlayer

#

typo

frigid wraith
#

doesnt print

spiral cove
#

did you fix the misspell

frigid wraith
#

its not misspelle

spiral cove
#

game.Players.LocalPlayer

#

it is tho

frigid wraith
#

waut

#

or

#

oh

spiral cove
frigid wraith
#

still doesnt print?

spiral cove
#

add a print above the if Arg ==

lime trailBOT
#

studio** You are now Level 8! **studio

spiral cove
#

line

#

and see if it is able to communicate with the server

#

figure out where the script stops

frigid wraith
#

that prints

spiral cove
#

also do local event = game.ReplicatedStorage:WaitForChild("NameTagEvent")

spiral cove
#

and see if the function is fired

frigid wraith
#

that wouldnt work

#

as the variable is in the function and when ur refrencing the variable its outside the function

#

no?

spiral cove
#

no

#

the event variable needs to be above the function

frigid wraith
#

yea

spiral cove
#

the print should be at the start of the function

frigid wraith
#

oooh

#

whoops

#

im so stupid

frigid wraith
#

dindt print

spiral cove
#

ok

#

where it says print("Fat") do

print(player)
print(Arg)
print(Data)

#

and show me the console

frigid wraith
#

ok

spiral cove
#

wtf

#

oh

#

right

#

that makes sense

#

in the local script

frigid wraith
#

the main one?

spiral cove
#

do event:FireServer("equipbutton", Data)

frigid wraith
#

or in the other one

spiral cove
#

local

#

script

frigid wraith
spiral cove
#

yes

#

test that

frigid wraith
#

still nothing

#

wai

#

it printed

frigid wraith
#

but idnt appear

#

above head

spiral cove
#

we are on the right track

frigid wraith
#

tru

#

right what now?

spiral cove
#

do

#

BillboardGui.StudsOffset = Vector3.new(0,4,0)

frigid wraith
spiral cove
#

yes

frigid wraith
#

not there

#

not appearing

spiral cove
#

console?

frigid wraith
spiral cove
#

whats that error below

frigid wraith
#

dednt see that

spiral cove
#

oh

#

you need to set it as paretn

#

parent

#

in the line above

#

BillboardGui.Parent = character.HumanoidRootPart

frigid wraith
#

do i remove line above thats aldready there?

spiral cove
#

???

frigid wraith
spiral cove
#

no just add ".Parent"

#

bruh

#

yeah

frigid wraith
#

sry

#

no more error but still no text

#

what now

#

as well as can we continue this tmrw cuz i need to go

spiral cove
#

no

#

its almost done lol

frigid wraith
#

right

#

so what now

spiral cove
#

BillboardGui.Size = UDim2.new(0.4,0,0.2,0)
BillboardGui.StudsOffset = Vector3.new(0,4,0)
textLabel.Size = UDim2.new(1,0,1,0)

#

there u go

frigid wraith
#

there is a label but the text isnt changing

spiral cove
#

yeah

#

ik

#

you need to assign the label text

#

you could do that however you want

#

like

#

from

Localscript
Data = {
labelText = "NewText"
}

Serverscript:
textLabel.Text = Data.labelText

#

but yeah

#

now its visible for everyone

#

you should be on the right path

frigid wraith
spiral cove
#

no

frigid wraith
spiral cove
#

wait

#
local Data = {
text = "NewText"
}

#

in the client script

#

and in the serverscript

#

do

#

textLabel.Text = Data.text

frigid wraith
spiral cove
#

no

#

dont have

#

a new table

#

in the serverscript

#

why are you doing that 😭

frigid wraith
#

ooh wait

spiral cove
#

YES!

frigid wraith
spiral cove
#

YES!!!

#

GOD hahahah

#

does it work right?

frigid wraith
#

ye

#

what now

spiral cove
#

you figure it out, you should have everything you need to go forward from here, use the table to pass information and let the server execute it

frigid wraith
#

right tysm

spiral cove
#

no problem

frigid wraith
#

should i just do like game.players.localplayer.playergui.textlabel.text = textlabel.text?

spiral cove
#

for the data table?

#

table works like this

(Variable)Name = Variable(Value)

When you want the value you refer to the name, just like how you refer to game.Players.Localplayer everytime you type player since player is already defined game.Players.Localplayer

#

Table is used to keep variables organized

frigid wraith
#

ye

spiral cove
#

local Data = {
text = player.playerGui.textlabel.text

}

#

should work

#

if you already have that path existing

#

if it doesnt exist it will error

frigid wraith
#

is there anyway i can reload it?

spiral cove
#

yeah

#

just update the Data table before sending a new event to the server

#

and change the server function with this

#

local function createInstance(instance,parent)
    return Instance.new(instance,parent)
end

local function updateLabel(player, Data)
    local character = workspace:WaitForChild(player.Name)
    print("nametag blah")
    local BillboardGui
    local textLabel
    if character:WaitForChild("HumanoidRootPart"):FindFirstChild("BillboardGui") then
        BillboardGui = character.HumanoidRootPart.BillboardGui
        textLabel = BillboardGui.TextLabel
    else
        BillboardGui = createInstance("BillboardGui",character.HumanoidRootPart)
        textLabel = createInstance("TextLabel",BillboardGui)
    end
    BillboardGui.Size = UDim2.new(0.4,0,0.2,0)
    BillboardGui.StudsOffset = Vector3.new(0,4,0)
    textLabel.Size = UDim2.new(1,0,1,0) 
    textLabel.Text = Data.text
end
#

I made it a function to make a new instance since then you can do more with that later on if you want to

#

like

#

assigning properties etc

frigid wraith
#

Ok tysm I’ll put that in

spiral cove
#

Np

frigid wraith
#

and if i want to change how it looks should i just change the font on the text label?

frigid wraith
spiral cove
#

Yeah

#

Looks good

frigid wraith
#

any ideas?

spiral cove
#

You need to update the data

#

Data = {
text = result
}

#

Then you send the remote event again after updating

#

Does that make sense?

frigid wraith
#

Sorry not really

frigid wraith