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

Help, you can buy Land Part 1, but not Land Part 2!?

Asked by 7 years ago

So in my tycoon, you can buy land one using a gui, but not land 2, and hey are almost similar so they should work. Any ideas on what's causing the problem?

Buy Land 1 WORKS

local players = game:GetService("Players")
local player = players.LocalPlayer
local name = player.Name

local light = game:GetService("Lighting")

local gui = player:WaitForChild("PlayerGui")
local gameui = gui:WaitForChild("GameGui")
local main = gameui:WaitForChild("MainFrame")
local gameplay = main:WaitForChild("Gameplay")
local buyiodine = gameplay:WaitForChild("BuyIodine")

local money = player.leaderstats.Money.Value
local crystals = player.leaderstats.Crystals.Value
local population = player.leaderstats.Population.Value

local enters = main:WaitForChild("EnterS")
local clicks = main:WaitForChild("ClickS")

local baseitems = light:WaitForChild("BaseItems")
local iodine = baseitems:WaitForChild("Iodine")

local land1 = iodine:WaitForChild("Lands1")
local buyland1 = buyiodine:WaitForChild("Land1")
local l1owned = land1:WaitForChild("IsPurchased").Value

buyland1.MouseEnter:connect(function(onEnter)
    wait(0.03)
    enters:Play()
end)
buyland1.MouseButton1Click:connect(function(onClicked)
    if l1owned == false then
        if money >= 0 then
            wait(0.03)
            clicks:Play()
            wait(0.03)
            money = money - 0
            l1owned = true
            land1:Clone().Parent = game.Workspace:WaitForChild("IodineTycoon")
            wait(1)
            buyland1:Destroy()
        end
    end
    if l1owned == true then
        wait(0.03)
        buyland1.TextColor3 = Color3.new(1, 0, 0)
        buyland1.Text = "Already Owned!"
        wait(2)
        buyland1.Text = "Land Part 1 - $0"
        buyland1.TextColor3 = Color3.new(1, 1, 1)
    end
end)

Buy Land 2 DOES NOT WORK

local players = game:GetService("Players")
local player = players.LocalPlayer
local name = player.Name

local light = game:GetService("Lighting")

local gui = player:WaitForChild("PlayerGui")
local gameui = gui:WaitForChild("GameGui")
local main = gameui:WaitForChild("MainFrame")
local gameplay = main:WaitForChild("Gameplay")
local buyiodine = gameplay:WaitForChild("BuyIodine")

local money = player.leaderstats.Money.Value
local crystals = player.leaderstats.Crystals.Value
local population = player.leaderstats.Population.Value

local enters = main:WaitForChild("EnterS")
local clicks = main:WaitForChild("ClickS")

local baseitems = light:WaitForChild("BaseItems")
local iodine = baseitems:WaitForChild("Iodine")

local land2 = iodine:WaitForChild("Lands2")
local buyland2 = buyiodine:WaitForChild("Land2")
local l2owned = land2:WaitForChild("IsPurchased").Value

buyland2.MouseEnter:connect(function(onEnter)
    wait(0.03)
    enters:Play()
end)
buyland2.MouseButton1Click:connect(function(onClicked)
    if l2owned == false then
        if money >= 50 then
            wait(0.03)
            clicks:Play()
            wait(0.03)
            money = money - 50
            l2owned = true
            land2:Clone().Parent = game.Workspace:WaitForChild("IodineTycoon")
            wait(1)
            buyland2:Destroy()
        end
    end
    if l2owned == true then
        wait(0.03)
        buyland2.TextColor3 = Color3.new(1, 0, 0)
        buyland2.Text = "Already Owned!"
        wait(2)
        buyland2.Text = "Land Part 1 - $0"
        buyland2.TextColor3 = Color3.new(1, 1, 1)
    end
end)
0
I had them in the same script somewhere before, and they STILL didn't work. Land 1, and 2 did, but not the small bank. The small bank STILL doesn't work, but now neither does land 2. Theevilem 23 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Quick note, do not get .Value on variables. Do this instead:

local money = player.leaderstats.Money
local crystals = player.leaderstats.Crystals
local population = player.leaderstats.Population

money.Value
crystals.Value
population.Value

That could be your problem.

Ad

Answer this question