\$\begingroup\$

I’m working on a Roblox tycoon game. I don’t know how to allow the player to buy things because just using: if tycoonPlayerMoney.Value >= 10 then. doesn’t work.

Here’s the script:

CurrencyName = "Money" --Name of the currency
StarterValue = 300   -- How much money You start with

--------------------------------Variables---------------------
    

v = script.Parent.Values.OwnerValue 
m1 = game.ReplicatedStorage.Mosques.Mosque1 --- Building of the tycoon
b = script.Parent.b --- Purchase Buttons

PayOut = 2 -- Amount of pay
WaitBetweenPayout = 10 -- How long it will take for the next pay
--After touching tycoon door
script.Parent.Touched:Connect(function(Hit)
---Make owner
    if Hit.Parent:FindFirstChild("Humanoid") and v.Value == nil then

        local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)

        v.Value = Player

        script.Parent.Transparency = 1 -- Door transparent
        script.Parent.CanCollide = false -- Door CanCollide off
        script.Parent.SurfaceGui.TextLabel.Text = tostring(v.Value).."'s Mosque" --Change Door Text

        local Repeat = true  --Repeat giving currrency
        
        local fold = Instance.new("Folder", Player) ----Currency
        fold.Name = "leaderstats" 
        tycoonPlayerMoney = Instance.new("IntValue", fold)
        tycoonPlayerMoney.Name = CurrencyName
        tycoonPlayerMoney.Value = StarterValue


        while true do ---Repeat paying every 10 seconds
            wait()
            if Repeat ==  true then
                wait(WaitBetweenPayout)
                tycoonPlayerMoney.Value = tycoonPlayerMoney.Value+PayOut 
            end
        end
-----Purchase Buttons
        b.a.Touched:connect(function(Hit)
            if Hit.Parent:FindFirstChild("Humanoid") then
                local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                if v.Value == Player and tycoonPlayerMoney.Value >= 10 then -- How much cost
                    m1.Mosq.Decorations.Outside.Stairs:Clone()
                    m1.Mosq.Decorations.Outside.Stairs.Parent = workspace.Mosques.mosque1
                    b.a:Destroy()
                    tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 10
                    PayOut = PayOut + 2
                    b.b.CanCollide = true
                    b.b.CanTouch = true
                    b.b.Transparency = 0
                    b.b.BillboardGui.Enabled = true --Gui that shows the price and name
                end
            end
        end)

        b.b.Touched:connect(function(Hit)
            if Hit.Parent:FindFirstChild("Humanoid") then
                local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                if v.Value == Player and  tycoonPlayerMoney.Value >= 25 then
                    m1.Mosq.Decorations.Outside.Sign:Clone()
                    m1.Mosq.Decorations.Outside.Sign.Parent = workspace.Mosques.mosque1
                    b.b:Destroy()
                    tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 25
                    PayOut = PayOut + 4
                    b.c.CanCollide = true
                    b.c.CanTouch = true
                    b.c.Transparency = 0
                    b.c.BillboardGui.Enabled = true
                end
            end
        end)

        b.c.Touched:connect(function(Hit)
            if Hit.Parent:FindFirstChild("Humanoid") then
                local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                if v.Value == Player and tycoonPlayerMoney.Value >= 45 then
                    m1.Mosq.WallsEtc.Roofnfloor.FloorF:Clone()
                    m1.Mosq.WallsEtc.Roofnfloor.FloorF.Parent = workspace.Mosques.mosque1
                    b.c:Destroy()
                    tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 45
                    PayOut = PayOut + 4
                    b.d.CanCollide = true
                    b.d.CanTouch = true
                    b.d.Transparency = 0
                    b.d.BillboardGui.Enabled = true
                    b.d.Touched:connect(function(Hit)
        b.d.Touched:connect(function(Hit)
                if Hit.Parent:FindFirstChild("Humanoid") then
                        local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                        if v.Value == Player and tycoonPlayerMoney.Value >= 25 then
                            m1.Mosq.WallsEtc.WallParts.WallPart1:Clone()
                            m1.Mosq.WallsEtc.WallParts.WallPart1.Parent = workspace.Mosques.mosque1
                            b.d:Destroy()
                            tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 25
                            PayOut = PayOut + 2
                            b.e.CanCollide = true
                            b.e.CanTouch = true
                            b.e.Transparency = 0
                            b.e.BillboardGui.Enabled = true 
                    end
                end
            end)
                    b.e.Touched:connect(function(Hit)
                        if Hit.Parent:FindFirstChild("Humanoid") then
                            local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                            if v.Value == Player and tycoonPlayerMoney.Value >= 25 then
                                m1.Mosq.WallsEtc.WallParts.WallPart2:Clone()
                                m1.Mosq.WallsEtc.WallParts.WallPart2.Parent = workspace.Mosques.mosque1
                                b.e:Destroy()
                                tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 25
                                PayOut = PayOut + 2
                                b.f.CanCollide = true
                                b.f.CanTouch = true
                                b.f.Transparency = 0
                                b.f.BillboardGui.Enabled = true 
                            end
                        end
                    end)        
                    b.f.Touched:connect(function(Hit)
                        if Hit.Parent:FindFirstChild("Humanoid") then
                            local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                            if v.Value == Player and tycoonPlayerMoney.Value >= 125 then
                                m1.Mosq.WallsEtc.Walls.EtcRoom.Wall1:Clone()
                                m1.Mosq.WallsEtc.Walls.EtcRoom.Wall1.Parent = workspace.Mosques.mosque1
                                b.f:Destroy()
                                tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 125
                                PayOut = PayOut + 6
                                b.g.CanCollide = true
                                b.g.CanTouch = true
                                b.g.Transparency = 0
                                b.g.BillboardGui.Enabled = true 
                            end
                        end
                    end)
                    b.g.Touched:connect(function(Hit)
                        if Hit.Parent:FindFirstChild("Humanoid") then
                            local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
                            if v.Value == Player and tycoonPlayerMoney.Value >= 45 then
                                m1.Mosq.WallsEtc.Walls.EtcRoom.Wall2:Clone()
                                m1.Mosq.WallsEtc.Walls.EtcRoom.Wall2.Parent = workspace.Mosques.mosque1
                                b.g:Destroy()
                                tycoonPlayerMoney.Value = tycoonPlayerMoney.Value - 45
                                PayOut = PayOut + 4

                            end
                        end
                    end)
                    end)
                end
            end
        end)
    end
end)      
```

\$\endgroup\$

1

You must log in to answer this question.

Browse other questions tagged .