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

How come adding one thing break this stat text script?

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

✓ Accepted answer

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!

1 comment

0

ahh okay. it didnt work in studip. thats what mixed me up

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