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

Script active even after reset?

After resetting the whole script does not affect the player anymore, how do you fix that?

local player = game.Players.LocalPlayer
while not player.Character do
    wait()
end
local character = player.Character



local bg = Instance.new("BillboardGui")
bg.Parent = player.PlayerGui
bg.Adornee = character.Head
bg.Active = true
bg.AlwaysOnTop = true
bg.Size = UDim2.new(1, 0, 1, 0)
bg.StudsOffset = Vector3.new(0, 2, 0)
local bgcopy = bg:Clone()
bgcopy.Parent = character.Head
 
local frame = Instance.new("Frame")
frame.Parent = bg
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundTransparency = 1
frame.BackgroundColor3 = Color3.new(1, 1, 1)
frame.Active = true
local framecopy = frame:Clone()
framecopy.Parent = character.Head.BillboardGui

 
local text = Instance.new("TextLabel")
text.Parent = frame
text.Position = UDim2.new(0.25, 0, 0.25, 0)
text.Size = UDim2.new(.5, 0, .5, 0)
text.BackgroundTransparency = 1
text.Text = (player.NamePl.Value)
text.FontSize = "Size24"
text.TextColor3 = Color3.new(255, 255,255)
text.TextStrokeTransparency = 0
text.Active = true
local textcopy = text:Clone()
textcopy.Parent = character.Head.BillboardGui.Frame




1 comment

0

Try referencing player.Character directly instead of using the character variable in your script. I've had this problem before and directly referencing player.Character fixed it for me.

1 answer

✓ Accepted answer

Put your script inside StarterPlayerScripts. Like StarterGear replicates to Backpack after respawn, StarterPlayerScripts replicates to PlayerScripts except PlayerScripts remains even after respawn.

Also i improved your script and optimized it for PlayerScripts.

repeat wait() until game.Players.LocalPlayer
local player = game.Players.LocalPlayer
player.CharacterAdded:connect(function(character)
local bg = Instance.new("BillboardGui", character.Head) -- 1) You need not clone the thing you just created - 2) There is a second "property" in the Instance.new constructor that sets the Parent
bg.Adornee = character.Head
bg.Active = true
bg.AlwaysOnTop = true
bg.Size = UDim2.new(1, 0, 1, 0)
bg.StudsOffset = Vector3.new(0, 2, 0)

local frame = Instance.new("Frame", character.Head:WaitForChild("BillboardGui")) --WaitForChild just in case
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundTransparency = 1
frame.BackgroundColor3 = Color3.new(1, 1, 1)
frame.Active = true

local text = Instance.new("TextLabel", character.Head.BillboardGui:WaitForChild("Frame"))
text.Position = UDim2.new(0.25, 0, 0.25, 0)
text.Size = UDim2.new(.5, 0, .5, 0)
text.BackgroundTransparency = 1
text.Text = (player.NamePl.Value)
text.FontSize = "Size24"
text.TextColor3 = Color3.new(255, 255,255)
text.TextStrokeTransparency = 0
text.Active = true
end)

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