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

What is the problem with this script?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

For some reason, all of the players money is stats2 are not being transfered.... this is what I have tried:

local stats = player:findFirstChild("leaderstats")
---------
amt= stats:FindFirstChild("Stored").Value 
---------

script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if (choice == script.Parent.Choice5) then
        if (player ~= nil) then
            local stats = player:findFirstChild("leaderstats")
            local otherStats = player:findFirstChild("Stats2")
            if (stats ~= nil and otherStats ~= nil) then
                local playerStored = otherStats:findFirstChild("Stored")
                if stats:findFirstChild("Money").Value >= amt then
                    otherStats:findFirstChild("Stored").Value = otherStats:findFirstChild("Stored").Value + amt
                    stats:findFirstChild("Money").Value = stats:findFirstChild("Money").Value - amt
                end
            end
        end
    end

    if (choice == script.Parent.Choice6) then
        if (player ~= nil) then
            local stats = player:findFirstChild("leaderstats")
            local otherStats = player:findFirstChild("Stats2")
            if (stats ~= nil and otherStats ~= nil) then
                local playerStored = otherStats:findFirstChild("Stored")
                if otherStats:findFirstChild("Stored").Value >= amt then
                    stats:findFirstChild("Money").Value = stats:findFirstChild("Money").Value + amt
                    otherStats:findFirstChild("Stored").Value = otherStats:findFirstChild("Stored").Value - amt             
                end
            end
        end
    end
end)
1
If this is the whole script, then `player` on line 1 is not defined. 1waffle1 2908 — 8y

Answer this question