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

PriceOwed is not a valid member of Folder? [SOLVED]

Asked by 6 years ago
Edited 6 years ago

I'm trying to make a button to where you can upgrade your speed and I was testing out the value changing so the GUI would know what to say. The code that I used to set the data is below.

game.Players.PlayerAdded:Connect(function(plr)
--// Spawn Teleport

    plr.CharacterAdded:Connect(function(player)
        wait()
        player.HumanoidRootPart.CFrame = CFrame.new(workspace.Spawn.Reference.Position)
    end)

--// Leaderboard

    local leaderstats = Instance.new("Folder", plr)
        leaderstats.Name = "leaderstats"
    local KOs = Instance.new("IntValue", leaderstats)
        KOs.Name = "KO's"
    local KillStreak = Instance.new("IntValue", leaderstats)
        KillStreak.Name = "Kill Sreak"

--// Shop Values
    local shopData = Instance.new("Folder", plr)
        shopData.Name = "ShopData"
    local priceOwed = Instance.new("IntValue", shopData)
        priceOwed.Name = "PriceOwed"
    local UpgradeBought = Instance.new("StringValue", shopData)
        UpgradeBought.Name = "UpgradeBought"
end)


For some reason, the script below this line can't findthe "PriceOwed" value in the folder.

script.Parent.Touched:Connect(function(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    if h then
        local name = hit.Parent.Name
        if game.Players:FindFirstChild(name) then
            game.Players[name].ShopData.PriceOwed = 100
            game.Players[name].ShopData.UpgradeBought = "Speed Upgrade"

            game.ServerStorage.AreYouSureGUI.Parent = game.Players[name].PlayerGui
        end
    end
end)

Sorry for the long scripts, I tried to make it easy to read but I'm unsure if it worked as I hoped it would. Thanks in advance for helping me solve this. -Cmgtotalyawesome

1 answer

Log in to vote
0
Answered by 6 years ago

If you were wondering what the solution was, I didn't say .Value when referring to "PriceOwed".

Ad

Answer this question