#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)
elaborate
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
peak code
ikr
i left making this game for a while cuz literally no one knew what was wrong :/
ill send a vid
why are all the table items just bangers font
you kinda have to set the tags adornee
tag.adornee = character.head
what is adornee sry
here
ok thanks
Tag.Adornee = character.Head
Offset?
dunno
interesting
very
is it printing anything
yeah
ah i see what might be causing it
Wait
if the changes in playergui are made locally, the server can't see them
therefore he doesn't know what raritylabel is
Do you even use billboardGUI?
yea
** You are now Level 11! **
And a text label that is decendant of that?
is it printing "nametag blah"
check
Do you want the text label to appear above the player?
** You are now Level 7! **
yea
is it a billboard gui
no 😦
then make it one
alr
Because if thats the case your gonna have to rearrange everything
make one
set the size to something like 6, 0, 1.2, 0
chuck it into starter gui?
Or maybe it works locally, but if its like a server thing where everyone can see the tag then it should be handled with billboardgui attached to the player's character head by the server
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
me neither
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
Was the billboard gui created with a localscript?
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
idk what to say, good luck with cleaning everything
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
for some reason there is so many errors that werent happening b4
im so confused bro
screenshot?
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
nonono
billboardgui doesnt have label properties
make a textlabel with billboardgui as parent
just change instance.new to "TextLabel"
why is textLabel visible false?
its not that
text label should be a bill boar gui
should i make current rarity gui text label?
your making me confused fr
do you want to let everyone see the text?
or only the local player?
then everything of that needs to be handled with a serverscript
i think something is something when its another thing
localscript = client only
serverscript = Server = everyone can see
you need to communicate with the server from the client
what should i do?
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
ok ty ty
with this shall i just create my own variables for the event?
yeah
alr
But keep in mind that there are some flaws
same for the first one as well
im not bothered as long as it works tbh
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
mm
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
what is replicated service?
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
ok
replicatedStorage*
its an error since its not defined yet
how would i define it
local currentRarityGui =
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
Data.currentRarityGui.Parent = character.HumanoidRootPart
im too confused tn lol
and change its offset to 4 on the Y axis
oh my bad
its .new
not .New
and remove player.Character
since you defined the character
only do character.HumanoidRootPart
yeah seems right
dk wat that A is doing there
does it work?
ill test
the Arg?
oh
what even is arg?
Argument
I know why
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
do i put anything in data
alr
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
alr
?
doesnt print
did you fix the misspell
still doesnt print?
add a print above the if Arg ==
** You are now Level 8! **
line
and see if it is able to communicate with the server
figure out where the script stops
that prints
also do local event = game.ReplicatedStorage:WaitForChild("NameTagEvent")
move the print above local character =
and see if the function is fired
that wouldnt work
as the variable is in the function and when ur refrencing the variable its outside the function
no?
yea
the print should be at the start of the function
dindt print
ok
where it says print("Fat") do
print(player)
print(Arg)
print(Data)
and show me the console
the main one?
do event:FireServer("equipbutton", Data)
or in the other one
we are on the right track
yes
console?
whats that error below
dednt see that
oh
you need to set it as paretn
parent
in the line above
BillboardGui.Parent = character.HumanoidRootPart
do i remove line above thats aldready there?
???
sry
no more error but still no text
what now
as well as can we continue this tmrw cuz i need to go
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
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
no
wait
local Data = {
text = "NewText"
}
in the client script
and in the serverscript
do
textLabel.Text = Data.text
YES!
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
right tysm
no problem
should i just do like game.players.localplayer.playergui.textlabel.text = textlabel.text?
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
ye
local Data = {
text = player.playerGui.textlabel.text
}
should work
if you already have that path existing
if it doesnt exist it will error
is there anyway i can reload it?
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
Ok tysm I’ll put that in
Np
and if i want to change how it looks should i just change the font on the text label?
👍 ?
?
You need to update the data
Data = {
text = result
}
Then you send the remote event again after updating
Does that make sense?
Sorry not really
^