Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come adding one thing break this stat text script?

Asked by 8 years ago

this script works

for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do
    for i,Values in pairs(script.Parent.Stats:GetChildren()) do
        local DName = Data.Name

        local VName = Values.Name

        if DName == VName then
            Values:FindFirstChild(DName)
            Values.Text = (VName) 



            end
    end
end

when i added that on line nine, it stopped working

for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do
    for i,Values in pairs(script.Parent.Stats:GetChildren()) do
        local DName = Data.Name

        local VName = Values.Name

        if DName == VName then
            Values:FindFirstChild(DName)
            Values.Text = (VName) ": "



            end
    end
end

Output of it when i added it

17:29:55.574 - Players.Player1.PlayerGui.ScreenGui.Index.Frame.LocalScript:9: attempt to call local 'VName' (a string value)

1 answer

Log in to vote
0
Answered by 8 years ago

Concatenation

If you are trying to combine the VName with ": ", then use .. to combine the two.

Let me show you an example:

local num = 5
print("There are "..num.." apples.")

This will print, "There are 5 apples." because the num variable is concatenated to the other 2 strings ("There are " and " apples").

Now for your script, let's take a look:

for i,Data in pairs(game.Players.LocalPlayer.Data:GetChildren()) do
    for i,Values in pairs(script.Parent.Stats:GetChildren()) do
        local DName = Data.Name

        local VName = Values.Name

        if DName == VName then
            Values:FindFirstChild(DName)
            Values.Text = VName..": " --Concatenation. (Also, you don't need ()s for "VName")



            end
    end
end

If you have any problems, please leave a comment below. Thank you and I hope this will help you!

0
ahh okay. it didnt work in studip. thats what mixed me up AwesomeSauce666556 0 — 8y
Ad

Answer this question