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

When trying to use ToString on a stringValue that has been found in the player it doesnt work?

Asked by 4 years ago

I am trying to create a player exeplorer where you can see all the players stats but when trying to get the players rank I get this error:

Players.deadwalker601.PlayerGui.AdminGui.Frame.Panels.PlayerInfo.Players.Script:48: attempt to call field 'ToString' (a nil value)
Stack Begin
Script 'Players.deadwalker601.PlayerGui.AdminGui.Frame.Panels.PlayerInfo.Players.Script', global findPlayers
Script 'Players.deadwalker601.PlayerGui.AdminGui.Frame.Panels.PlayerInfo.Players.Script', Line 53
Stack End

Is there something wrong with my code?

function findPlayers()
    for i,v in pairs(game.Players:GetChildren()) do
        local childName = v.Name
        local childCash = v.PlayerStats:WaitForChild("Cash")
        local childRank = v.PlayerStats:WaitForChild("PlayerRank")

        local frame = Instance.new("Frame")
        frame.Parent = script.Parent
        frame.Name = childName
        frame.BackgroundColor3 = Color3.new(0,170,255)
        frame.BackgroundTransparency = 0.5
        frame.BorderSizePixel = 0

        local playerName = Instance.new("TextLabel")
        playerName.Parent = frame
        playerName.Name = "PlayerName"
        playerName.Size = UDim2.new(0.325,0,1,0)
        playerName.Position = UDim2.new(0,0,0,0)
        playerName.BackgroundColor3 = Color3.new(0,170,255)
        playerName.BackgroundTransparency = 0
        playerName.BorderSizePixel = 0
        playerName.TextScaled = true
        playerName.Font = Enum.Font.Gotham
        playerName.Text = childName

        local playerCash = Instance.new("TextLabel")
        playerCash.Parent = frame
        playerCash.Name = "playerCash"
        playerCash.Size = UDim2.new(0.2,0,1,0)
        playerCash.Position = UDim2.new(0.325,0,0,0)
        playerCash.BackgroundColor3 = Color3.new(0,170,255)
        playerCash.BackgroundTransparency = 0
        playerCash.BorderSizePixel = 0
        playerCash.TextScaled = true
        playerCash.Font = Enum.Font.Gotham
        playerCash.Text = childCash.Value

        local playerRank = Instance.new("TextLabel")
        playerRank.Parent = frame
        playerRank.Name = "playerRank"
        playerRank.Size = UDim2.new(0.2,0,1,0)
        playerRank.Position = UDim2.new(0.525,0,0,0)
        playerRank.BackgroundColor3 = Color3.new(0,170,255)
        playerRank.BackgroundTransparency = 0
        playerRank.BorderSizePixel = 0
        playerRank.TextScaled = true
        playerRank.Font = Enum.Font.Gotham
        playerRank.Text = v.PlayerStats.PlayerRank.Value.ToString()
    end 
end

wait(3)
findPlayers()
0
Try changing from `v.PlayerStats.PlayerRank.Value.ToString()` to `tostring(v.PlayerStats.PlayerRank.Value)` cailir 284 — 4y
0
Yep mybituploads 304 — 4y
0
ok EDIT:it worked deadwalker601 110 — 4y

Answer this question