I added prints at
RealPlayer.Humanoid.Died:Connect(function()
wait(4)
print("yay")
Text()
end)
but it simply wont work, and the output says “yay” like intended.
Heres the full script
game.Players.PlayerAdded:Connect(function(Player)
wait(2)
local Character = Player.Character
local PrimaryPart = Character.PrimaryPart
local RealPlayer = game.Workspace:FindFirstChild(Player.Name)
local function Text()
local bbg = Instance.new("BillboardGui")
local Text = Instance.new("TextLabel")
bbg.Parent = RealPlayer.Head
Text.RichText = true
Text.FontFace.Weight = Enum.FontWeight.Bold
Text.Parent = bbg
Text.Text = "<b>" .. Player.Name .. "</b>"
bbg.StudsOffset = Vector3.new(0, 1.5, 0)
Text.TextStrokeTransparency = 0
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
bbg.Size = UDim2.new(0, 300, 0, 50)
Text.Size = UDim2.new(0, 300, 0, 50)
bbg.MaxDistance = 15
Text.TextScaled = true
Text.BackgroundTransparency = 1
end
Text()
RealPlayer.Humanoid.Died:Connect(function()
wait(4)
print("yay")
Text()
end)
end)
1 Like
Is your title a shrimp pun there? Also, I think you placed this as the wrong category - should be in #help-and-feedback:scripting-support .
1 Like
So does this print or not, I’m confused by how you phrased this. Were there any output messages besides the prints, if they do work?
It prints out “yay” once I died, but the overhead gui wont appear back above my head
I think the problem here is that you aren’t using CharacterAdded
to detect when the Player’s Character respawns. Basically, PlayerAdded
will only fire once - when the Player joins the game, thus adding the Player instance in the Player
service. However, CharacterAdded
will be fired every time a Player’s character in Workspace
respawns or gets added.
To solve this, simply connect CharacterAdded
to a function, and run the Text()
function:
game.Players.PlayerAdded:Connect(function(Player)
-- Code here.
Player.CharacterAdded:Connect(function(character)
Text()
end)
end)
1 Like
Didn’t work for some reason, I also used print()
Could you show the current script revision / the script’s hierarchy?
game.Players.PlayerAdded:Connect(function(Player)
wait(2)
local Character = Player.Character
local PrimaryPart = Character.PrimaryPart
local RealPlayer = game.Workspace:FindFirstChild(Player.Name)
local function Text()
local bbg = Instance.new("BillboardGui")
local Text = Instance.new("TextLabel")
bbg.Parent = RealPlayer.Head
Text.RichText = true
Text.FontFace.Weight = Enum.FontWeight.Bold
Text.Parent = bbg
Text.Text = "<b>" .. Player.Name .. "</b>"
bbg.StudsOffset = Vector3.new(0, 1.5, 0)
Text.TextStrokeTransparency = 0
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
bbg.Size = UDim2.new(0, 300, 0, 50)
Text.Size = UDim2.new(0, 300, 0, 50)
bbg.MaxDistance = 15
Text.TextScaled = true
Text.BackgroundTransparency = 1
end
Player.CharacterAdded:Connect(function(character)
print("YEA")
Text()
end)
end)
Why are you doing this? Doesn’t Player.Character
already point to the Player itself? Try to replace RealPlayer.Head
with Character.Head
and see if it fixes anything.
Also, for the simplicity of the Script, I would suggest to make your overhead nametag in Studio, and store it in ServerStorage
to clone. Not essential to follow though.
I will switch RealPlayer with Character then (it worked)
Also, Player.CharacterAdded:Connect(function(character)
didn’t work for some reason
Maybe remove the parameter character
, since we already have a variable that’s pointing to the Player’s Character.
Now it printed, but the name above the player doesn’t appear now
Furlicious:
local bbg = Instance.new("BillboardGui")
local Text = Instance.new("TextLabel")
bbg.Parent = RealPlayer.Head
Text.RichText = true
Text.FontFace.Weight = Enum.FontWeight.Bold
Text.Parent = bbg
Text.Text = "<b>" .. Player.Name .. "</b>"
bbg.StudsOffset = Vector3.new(0, 1.5, 0)
Text.TextStrokeTransparency = 0
Text.TextColor3 = Color3.fromRGB(255, 255, 255)
bbg.Size = UDim2.new(0, 300, 0, 50)
Text.Size = UDim2.new(0, 300, 0, 50)
bbg.MaxDistance = 15
Text.TextScaled = true
Text.BackgroundTransparency = 1
I don’t know for sure, maybe because the Text()
function doesn’t have a variable in it that points to the Player’s Character? You can try to include a variable inside there.
I changed it to Character.Head, so I am not sure about what you meant…
I fixed it! The script was unsure about what variables were what-
Player.CharacterAdded:Connect(function(character)
bbg.Parent = character.Head -- notice how we use the new variable
1 Like
system
(system)
Closed
August 15, 2023, 7:31am
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.