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

how do i put variables in a string?

Asked by 2 years ago
player = workspace.Parent.Players.LocalPlayer.Name
while true do
    wait(1)
    cash = workspace.Parent.Players..player.Backpack.DataFolder.Currency.Value
    script.Parent.Parent.Counter.Text = cash
end

This is just a simple piece of code that I ripped from my script. I'm trying to constantly update a value for multiple players, so I can't use localplayer.

I have no Idea how to do this, and if anybody can show me how I can do this I would greatly appreciate it!

0
what exactly are you trying to achieve, like what would you want the string to look like in the end? Benbebop 1049 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

I would assume from your code you are trying to update a GUI to show each players money.

I wrote this that goes through each player in the game and if the DataFolder is loaded then updates the TextBox GUI that the is the scripts parent to show the players currency. For 1 second and then show the next players and so on.

I put this code in a server script as a child to the TextBox, you will need to use a server script if you want to be able to read all players currency.

local Players = game:GetService("Players")

while true do
    for _, player in pairs(Players:GetPlayers()) do
        if player.Backpack:FindFirstChild("DataFolder") then
            local cash = player.Backpack:FindFirstChild("DataFolder").Currency.Value
            script.Parent.Text = cash
            wait(1)
        end
    end

    wait(1)
end
Ad

Answer this question