Trying to do an update script? Any help?

So I have this script located in a textbox, located in a frame, located in a billboard gui, located in a players head. So any help with this script not working?

local character = script.Parent.Parent.Parent.Parent.Parent

local Player = game.Players:GetPlayerFromCharacter(character)

Player.leaderstats.FirstName.Changed:Connect(function(newValue)

if newValue == true then

script.Parent.Text = Player.leaderstats.FirstName

end

end)
1 Like

well you can

script.Parent.Text = Player.leaderstats.FirstName.Value
or
script.Parent.Text = newValue

FirstName is a StringValue object, yes?

1 Like

It’s hard for us to tell without having access to the place but I’d start by throwing in some print statements so you can see what’s not working.
local character = script.Parent.Parent.Parent.Parent.Parent

local Player = game.Players:GetPlayerFromCharacter(character)
Player.leaderstats.FirstName.Changed:Connect(function(newValue)
print("Changed")
if newValue == true then
print("NewValue is true")
script.Parent.Text = Player.leaderstats.FirstName
end
end)

But I’m guessing your issue is with “if newValue == true then”. Instead of checking if it equals true, instead check if it exists. So try replacing that line with “if newValue then” and use those print statements to see what the output is telling you.

1 Like

I totally forgot the mention the output error on the

`

Player.leaderstats.FirstName.Changed:Connect(function(newValue)

`

remove the
if block
newValue is a string it will never == true

you can

if newValue then

but that is redundant since that’s why the event is firing.

try this
local character = script.Parent.Parent.Parent.Parent.Parent
local Player = game.Players:GetPlayerFromCharacter(character)

Player.leaderstats.FirstName.Changed:Connect(function(newValue)
  script.Parent.Text = newValue
end)
1 Like

I got this now, what am I doing wrong?

local player = script.Parent.Parent.Parent.Parent.Parent.Parent

local Character = player.Character

script.Parent.MouseButton1Click:connect(function()

player.leaderstats.FirstName.Value = script.Parent.Text

Character.Head.Title.F.T.Text = player.leaderstats.FirstName.Value.." "..player.leaderstats.LastName.Value

end)
1 Like

why is it now a Click event? i feel like you went backwards :confused:

1 Like

So the way I change the value of the name is by clicking a button, at first I tried to have it change when the text got updated, but now im trying to make it change when you actually click the name.

did you try my function here

yeah. i had no luck though… :frowning:

well what is it you want to happen?
Your intention?

From your first post it looks like you have a name in leaderstats that you want to be shown above their head.

script.Parent.MouseButton1Click:connect(function() -- Change to "Connect"

player.leaderstats.FirstName.Value = script.Parent.Text -- Put WaitForChild() on "leaderstats" and maybe "FirstName".

Character.Head.Title.F.T.Text = player.leaderstats.FirstName.Value.." "..player.leaderstats.LastName.Value

end)

Are you waiting for the leaderstats to exist? You probably should use WaitForChild().

connect is also deprecated, use Connect instead (Capitalize c)

Also, is this a local or server script?

its local, i tried all these and it hasn’t worked.

Why didnt you say so :sweat_smile:

you can just do game.Players.LocalPlayer to get the local player, then from there:

game:GetService("Players").LocalPlayer:WaitForChild("leaderstats'):WaitForChild("FirstName").Value -- Will get the player's stat

(If I did something wrong or terrible, just quote me on it)

1 Like

Oh my goodness, im so sorry, I meant server, i apologize for my mistake.

You can get the player via the click

1 Like

Oh yeah, i forgot about that. thanks ill test it.