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

Can I use a for loop to change a string value?

Asked by 6 years ago

I am in a situation where I need this for loop to change a couple string values. I can't find anywhere online where it says it is possible, but I can't see anywhere that it's impossible. Here's my script. Can anybody help.

local RS = game.ReplicatedStorage
local Open1v1Server = RS.Open1v1Server

local P1 = fifthFrame.Player1
local P2 = fifthFrame.Player2
local children = Open1v1Server.Players:GetChildren()
for i = 2, #children do
    P1.PlayerName.Value = i, children.Name
    P2.PlayerName.Value = i, children.Name
end

1 answer

Log in to vote
2
Answered by
thebayou 441 Moderation Voter
6 years ago

Of course it's possible. However, the method you're doing it makes no sense.

P1.PlayerName.Value = i, children.Name

What are you trying to do here? First of all, children doesn't HAVE a Name attribute, and you can't set a string value to two things (i, children.Name)

If you're trying to set it to the value of i concatenated with the name OF the value associated with i in the children array, you would make it

P1.PlayerName.Value = i .. children[i].Name
Ad

Answer this question