Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script.Parent.Visible = false
- game.Players.LocalPlayer:WaitForChild("BaseDataLoaded")
- script.Parent.Visible = true
- local MoneyLib = require(game.ReplicatedStorage.MoneyLib)
- wait() -- trust me on this one!
- local Busy = false
- function getItemById(Id)
- for i,v in pairs(game.ReplicatedStorage.Items:GetChildren()) do
- if v.ItemId.Value == Id then
- return v
- end
- end
- return nil
- end
- function setColor(gui, newColor)
- -- no fancy animation. (Gui 9-slices)
- local c = gui:GetChildren()
- local oldColor = gui.Center.BackgroundColor3
- for i = 1, #c do
- if c[i]:FindFirstChild("ImageLabel") then
- c[i].ImageLabel.ImageColor3 = newColor
- end
- c[i].BackgroundColor3 = newColor
- end
- end
- function changeColor(gui, newColor)
- -- this should fade out the old color to the new one (for 9-slices)
- local c = gui:GetChildren()
- local oldColor = gui.Center.BackgroundColor3
- for i = 1, 10 do
- local color = Color3.new((oldColor.r/10)*(10-i) + (newColor.r/10)*i,(oldColor.g/10)*(10-i) + (newColor.g/10)*i,(oldColor.b/10)*(10-i) + (newColor.b/10)*i)
- for i = 1, #c do
- if c[i]:FindFirstChild("ImageLabel") then
- c[i].ImageLabel.ImageColor3 = color
- end
- c[i].BackgroundColor3 = color
- end
- game:GetService("RunService").Heartbeat:wait()
- end
- end
- local function selectItem(ItemId)
- local Item = getItemById(ItemId)
- script.Parent.YYLeft.Inventory.Selected.ItemName.Text = Item.Name
- script.Parent.YYLeft.Inventory.Selected.ItemNameDark.Text = Item.Name
- local Tier = game.ReplicatedStorage.Tiers:FindFirstChild(Item.Tier.Value)
- script.Parent.YYLeft.Inventory.Selected.Type.Text = Tier.TierName.Value
- script.Parent.YYLeft.Inventory.Selected.TypeDark.Text = Tier.TierName.Value
- script.Parent.YYLeft.Inventory.Selected.Tier.BackgroundColor3 = Tier.TierColor.Value
- script.Parent.YYLeft.Inventory.Selected.Item.Icon.Image = "rbxassetid://"..Item.ThumbnailId.Value
- script.Parent.YYLeft.Inventory.Selected.Desc.Text = Item.Description.Value
- if Item.Tier.Value == 31 or Item.Tier.Value == 78 then
- script.Parent.YYLeft.Inventory.Selected.Type.TextColor3 = Color3.new(0,0,0)
- else
- script.Parent.YYLeft.Inventory.Selected.Type.TextColor3 = Color3.new(1,1,1)
- end
- if (Item.Tier.Value == 40 or Item.Tier.Value == 41 or Item.Tier.Value == 30 or Item.Tier.Value == 31 or Item.Tier.Value == 99 or Item.Tier.Value == 78) then
- local c = Tier.TierBackground.Value
- changeColor(script.Parent.YYLeft.Inventory.Selected.Blue, Color3.new(c.r/2,c.g/2,c.b/2))
- script.Parent.YYLeft.Inventory.Selected.Rare.Value = true
- else
- script.Parent.YYLeft.Inventory.Selected.Rare.Value = false
- changeColor(script.Parent.YYLeft.Inventory.Selected.Blue, Color3.new(50/255, 150/255, 200/255))
- end
- end
- local Player = game.Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local DefaultMouseIcon = Mouse.Icon
- Mouse.TargetFilter = nil
- function GetTycoon()
- local TycoonVal = game.Players.LocalPlayer:FindFirstChild("PlayerTycoon")
- if TycoonVal then
- if TycoonVal.Value then
- return TycoonVal.Value
- end
- end
- for i, Tycoon in pairs(game.Workspace.Tycoons:GetChildren()) do
- if Tycoon.Name:sub(1, 7) == "Factory" and Tycoon:IsA("Model") then
- if Tycoon.Owner.Value == game.Players.LocalPlayer.Name then
- return Tycoon
- end
- end
- end
- return nil
- end
- function RoundByThree(Number)
- if math.floor(Number) == Number then
- if Number%3 == 0 then
- return Number
- elseif (Number - 1)%3 == 0 then
- return Number - 1
- elseif (Number + 1)%3 == 0 then
- return Number + 1
- end
- end
- return Number
- end
- local Placing = false
- local GoodPlacement = false
- local Visual
- local Rotation = 0
- local InputService = game:GetService("UserInputService")
- local Debounce = false
- local cDebounce = false
- local LastItem
- function Rotate()
- if Rotation >= 360 then
- Rotation = 0
- end
- Rotation = Rotation + 90
- end
- local wDebounce = false
- function undo()
- if not Busy and game.Players.LocalPlayer:FindFirstChild("Rebirthing") == nil then
- if not wDebounce and Placing then
- wDebounce = true
- if LastItem then
- script.Parent.Sounds.Withdraw.Pitch = 1 + (math.random(-100,100)/500)
- script.Parent.Sounds.Withdraw:Play()
- local success = game.ReplicatedStorage.DestroyItem:InvokeServer(LastItem)
- LastItem = nil
- else
- script.Parent.Sounds.Error:Play()
- end
- wait(0.3)
- wDebounce = false
- end
- end
- end
- local function off()
- Placing = false
- script.Parent.YYRight.Placement:TweenPosition(UDim2.new(0,0,0.6,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quart,0.5,true)
- game:GetService("ContextActionService"):UnbindAction("PlaceItem")
- if game:GetService("UserInputService").TouchEnabled then
- game.Players.LocalPlayer.PlayerGui.TouchGui.TouchControlFrame.Visible = true
- end
- if not InputService.GamepadEnabled then
- Mouse.Icon = DefaultMouseIcon
- end
- spawn(function()
- if game.Players.LocalPlayer.MOTD.Value ~= game.ReplicatedStorage.MOTD.Value then
- game.ReplicatedStorage.MOTDRead:InvokeServer()
- end
- end)
- Mouse.TargetFilter = nil
- local y = 50
- script.Parent.YYLeft.Inventory.Visible = false
- script.Parent.YYRight.Shop.Visible = false
- script.Parent.YYCenter.BaseSettings.Visible = false
- script.parent.YYCenter.BoxesMenu.Visible = false
- script.Parent.YYCenter.Purchases.Visible = false
- script.Parent.YYCenter.Gift.Visible = false
- script.Parent.YYCenter.EventShop.Visible = false
- for i,Child in pairs(script.Parent.YYCenter:GetChildren()) do
- Child.Visible = false
- end
- if Visual then
- Visual.Parent = nil
- Visual = nil
- end
- for i, TycoonItem in pairs(GetTycoon():GetChildren()) do
- if game.ReplicatedStorage.Items:FindFirstChild(TycoonItem.Name) and TycoonItem:IsA("Model") then
- local SelBox = TycoonItem:FindFirstChild("SelectionBox")
- if SelBox then
- SelBox.Visible = false
- end
- end
- end
- end
- local function updatedetails()
- local Item = script.Parent.Hovering.Hover.Object.Value
- if Item and script.Parent.Hovering.Hover.Details.Value then
- if Item.ItemType.Value == 6 or Item.ItemType.Value == 99 then
- script.Parent.Hovering.Hover.Copy.Desc.Text = "Can't Copy"
- script.Parent.Hovering.Hover.Sell.Desc.Text = "Can't Sell"
- else
- script.Parent.Hovering.Hover.Sell.Desc.Text = "Sell "..MoneyLib.HandleMoney(Item.Cost.Value * 0.3)
- if Item.ItemType.Value == 7 and Item:FindFirstChild("Crystals") then
- script.Parent.Hovering.Hover.Copy.Desc.Text = "Copy "..MoneyLib.DealWithPoints(Item.Crystals.Value)
- else
- script.Parent.Hovering.Hover.Copy.Desc.Text = "Copy "..MoneyLib.HandleMoney(Item.Cost.Value)
- end
- end
- end
- end
- script.Parent.Hovering.Hover.Details.Changed:connect(updatedetails)
- local function withdrawselected()
- if script.Parent.Hovering.Hover.MultiSelect.Value then
- local Items = {}
- for i,Child in pairs(GetTycoon():GetChildren()) do
- if Child:FindFirstChild("Hitbox") and Child.Hitbox:FindFirstChild("MultiSelectBox") then
- table.insert(Items,Child)
- end
- end
- if #Items > 0 and not Debounce then
- Debounce = true
- local Success = game.ReplicatedStorage.DestroySelected:InvokeServer(Items)
- if Success then
- script.Parent.Sounds.Withdraw:Play()
- script.Parent.Hovering.Hover.Close:Fire()
- wait(0.1)
- else
- script.Parent.Sounds.Error:Play()
- wait(0.3)
- end
- Debounce = false
- end
- else
- local Item = script.Parent.Hovering.Hover.Object.Value
- if Item and Item:IsDescendantOf(GetTycoon()) and not Debounce then
- Debounce = true
- local Success = game.ReplicatedStorage.DestroyItem:InvokeServer(Item)
- if Success then
- script.Parent.Sounds.Withdraw:Play()
- script.Parent.Hovering.Hover.Close:Fire()
- wait(0.1)
- else
- script.Parent.Sounds.Error:Play()
- wait(0.3)
- end
- Debounce = false
- end
- end
- end
- local function copyselected()
- local Item = script.Parent.Hovering.Hover.Object.Value
- if Item and Item:IsDescendantOf(GetTycoon()) and not Debounce then
- Debounce = true
- local Success = game.ReplicatedStorage.BuyItem:InvokeServer(Item.Name,1)
- if Success then
- script.Parent.Sounds.Purchase:Play()
- wait(0.1)
- else
- script.Parent.Sounds.Error:Play()
- wait(0.3)
- end
- Debounce = false
- end
- end
- local function sellselected()
- local Item = script.Parent.Hovering.Hover.Object.Value
- if Item and Item:IsDescendantOf(GetTycoon()) and not Debounce then
- Debounce = true
- local Success = game.ReplicatedStorage.SellItem:InvokeServer(Item)
- if Success then
- script.Parent.Sounds.Purchase:Play()
- script.Parent.Hovering.Hover.Close:Fire()
- wait(0.1)
- else
- script.Parent.Sounds.Error:Play()
- wait(0.3)
- end
- Debounce = false
- end
- end
- script.Parent.Hovering.Hover.Copy.Button.MouseButton1Click:connect(function()
- copyselected()
- end)
- script.Parent.Hovering.Hover.Sell.Button.MouseButton1Click:connect(function()
- sellselected()
- end)
- script.Parent.Hovering.Hover.Withdraw.Button.MouseButton1Click:connect(function()
- withdrawselected()
- end)
- game:GetService("UserInputService").InputBegan:Connect(function(key)
- if script.Parent.Hovering.Hover.Details.Value then
- if key.KeyCode == Enum.KeyCode.Z then
- withdrawselected()
- elseif key.KeyCode == Enum.KeyCode.X then
- sellselected()
- elseif key.KeyCode == Enum.KeyCode.C then
- copyselected()
- end
- elseif Placing then
- if key.KeyCode == Enum.KeyCode.R then
- Rotate()
- elseif key.KeyCode == Enum.KeyCode.F then
- undo()
- elseif key.KeyCode == Enum.KeyCode.Q then
- off()
- end
- end
- end)
- local function Place()
- if Placing then
- local Tycoon = GetTycoon()
- --Visual.Parent = Tycoon
- if Visual and not Debounce then
- if GoodPlacement then
- Debounce = true
- --PlaceItem:InvokeServer(Visual, Tycoon) --Yeah pretty sure Instances don't replicate so lets be safe, huh?
- local model = game.ReplicatedStorage.PlaceItem:InvokeServer(Visual.Name, Tycoon, CFrame.new(Visual.Hitbox.Position)*CFrame.Angles(0,(math.pi * (Rotation/180) ),0),Rotation)
- if model == nil then
- script.Parent.Sounds.Error:Play()
- else
- GoodPlacement = false
- LastItem = model
- script.Parent.Sounds.Placement.Pitch = 1 + (math.random(-100,100)/500)
- script.Parent.Sounds.Placement:Play()
- end
- else
- script.Parent.Sounds.Error:Play()
- end
- end
- if Visual then
- local Count = game.ReplicatedStorage.HasItem:InvokeServer(Visual.ItemId.Value)
- if Count > -1 then
- -- script.Parent.CurrentlyPlacing.Count.Text = "x"..Count
- script.Parent.YYRight.Placement.Amount.Text = "x"..Count
- script.Parent.YYRight.Placement.AmountDark.Text = "x"..Count
- end
- if Count <= 0 then
- off()
- end
- end
- wait(0.1)
- Debounce = false
- end
- end
- local function OpenEventShop()
- off()
- script.Parent.YYCenter.EventShop.Position = UDim2.new(-0.5,0,1,10)
- script.Parent.YYCenter.EventShop.Visible = true
- script.Parent.YYCenter.EventShop:TweenPosition(UDim2.new(-0.5,0,0.25,0),"InOut","Quart",0.25,true)
- end
- local cDebounce
- local function onClick()
- if InputService.MouseEnabled then
- if Placing then
- Place()
- elseif Mouse.Target and Mouse.Target:FindFirstChild("ClickDetector") then
- if not cDebounce then
- if Mouse.Target:IsDescendantOf(workspace.Market) then
- cDebounce = true
- script.Parent.Sounds.Click:Play()
- OpenEventShop()
- wait(0.3)
- cDebounce = false
- else
- cDebounce = true
- game.ReplicatedStorage.Click:FireServer(Mouse.Target)
- wait(0.1)
- cDebounce = false
- end
- end
- --[[
- else
- if Mouse.Target and UsingMouse and not InputService.GamepadEnabled then
- if Mouse.Target:IsDescendantOf(GetTycoon()) and Mouse.Target.Parent:IsA("Model") and Mouse.Target.Parent ~= GetTycoon() and Mouse.Target.Name == "Hitbox" then
- if not ItemMenu.Working.Visible and not ItemMenu.Error.Visible then
- -- ItemMenu.Visible = true
- -- ItemMenu.Position = UDim2.new(0, Mouse.X + 20, 0, Mouse.Y + 5 )
- -- ItemMenu.Object.Value = Mouse.Target.Parent
- end
- elseif Mouse.Target:FindFirstChild("ClickDetector") then
- if not cDebounce then
- cDebounce = true
- -- ItemMenu.Visible = false
- game.ReplicatedStorage.Click:FireServer(Mouse.Target)
- wait(0.05)
- cDebounce = false
- end
- else
- ItemMenu.Visible = false
- end
- else
- ItemMenu.Visible = false
- end
- ]]
- end if not InputService.GamepadEnabled then
- Mouse.Icon = DefaultMouseIcon
- end
- elseif InputService.GamepadEnabled then
- if Placing then
- Place()
- end
- end
- end
- -- Final Placement
- if InputService.TouchEnabled then
- InputService.TouchTap:connect(onClick)
- end
- Mouse.Button1Down:connect(onClick)
- local UsingMouse = true
- function InitiatePlacing(ItemBtn)
- if false then
- -- script.Parent.ItemSettings.Visible = false
- else
- if game.ReplicatedStorage.HasItem:InvokeServer(ItemBtn.ItemId.Value) > 0 and ItemBtn.ItemId.Value > 0 and not Placing and UsingMouse then
- -- script.Parent.Cancel.Visible = true
- Placing = true
- if script.Parent.Hovering.Hover.Details.Value then
- script.Parent.Hovering.Hover.Close:Fire()
- end
- GoodPlacement = false
- if not InputService.GamepadEnabled then
- Mouse.Icon = "rbxassetid://209048202"
- end
- game.ContextActionService:BindAction("PlaceItem",Place,false,Enum.KeyCode.ButtonR2)
- script.Parent.YYCenter.ObjectPlacement.Visible = true
- -- script.Parent.Undo.Visible = true
- -- script.Parent.Place.Visible = (InputService.GamepadEnabled or (InputService.TouchEnabled and not InputService.MouseEnabled))
- if Mouse then
- Mouse.TargetFilter = workspace.Tycoons
- end
- script.Parent.YYLeft.Inventory.Visible = false
- if game:GetService("UserInputService").TouchEnabled then
- game.Players.LocalPlayer.PlayerGui.TouchGui.TouchControlFrame.Visible = true
- end
- local toClone = getItemById(ItemBtn.ItemId.Value)
- if toClone then
- Visual = toClone:clone()
- local LocalItemTag = Instance.new("BoolValue")
- LocalItemTag.Name = "LocalItem"
- LocalItemTag.Parent = Visual
- Visual.Parent = GetTycoon()
- if Visual then
- -- script.Parent.CurrentlyPlacing.Thumbnail.Image = "rbxassetid://" .. Visual.ThumbnailId.Value
- -- script.Parent.CurrentlyPlacing.Count.Text = "x" .. game.ReplicatedStorage.HasItem:InvokeServer(Visual.ItemId.Value)
- script.Parent.YYRight.Placement.Image.Image = "rbxassetid://" .. Visual.ThumbnailId.Value
- local Amount = "x" .. game.ReplicatedStorage.HasItem:InvokeServer(Visual.ItemId.Value)
- script.Parent.YYRight.Placement.Amount.Text = Amount
- script.Parent.YYRight.Placement.AmountDark.Text = Amount
- local EndPosition = UDim2.new(1,-300,0.6,0)
- if not game:GetService("UserInputService").TouchEnabled then
- -- script.Parent.CurrentlyPlacing:TweenPosition(EndPosition,Enum.EasingDirection.InOut,Enum.EasingStyle.Quart,0.5)
- script.Parent.YYRight.Placement:TweenPosition(UDim2.new(-0.235,0,0.6,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quart,0.5, true)
- end
- end
- for i, TycoonItem in pairs(GetTycoon():GetChildren()) do
- if game.ReplicatedStorage.Items:FindFirstChild(TycoonItem.Name) and TycoonItem:IsA("Model") then
- local SelBox = TycoonItem:FindFirstChild("SelectionBox")
- if SelBox then
- SelBox.Visible = true
- SelBox.Transparency = 0.6
- end
- end
- end
- for i,v in pairs(workspace.Boxes:GetChildren()) do
- v.Visible = true
- end
- Visual.Hitbox.Transparency = 0.6
- Visual.Hitbox.Reflectance = 0.2
- local bMesh = Instance.new("BlockMesh",Visual.Hitbox)
- bMesh.Scale = Vector3.new(1,1000,1)
- if Visual:FindFirstChild("SelectionBox") then
- Visual.SelectionBox.Visible = true
- Visual.SelectionBox.Transparency = 0
- end
- for ii,vv in pairs(Visual.Model:GetChildren()) do
- if vv:IsA("BasePart") then
- vv.CanCollide = false
- vv.Anchored = true
- if vv.Name == "Colored" then
- vv.BrickColor = game.Players.LocalPlayer.TeamColor
- end
- end
- end
- local TycoonBase = GetTycoon().Base
- local TycoonTopLeft = TycoonBase.CFrame * CFrame.new(Vector3.new(TycoonBase.Size.x/2, 0, TycoonBase.Size.z/2))
- local ModelItemId = Instance.new("IntValue", Visual)
- ModelItemId.Name = "ItemId"
- ModelItemId.Value = ItemBtn.ItemId.Value
- local Hitbox = getItemById(ItemBtn.ItemId.Value).Hitbox:clone()
- Hitbox.Parent = Visual
- Visual.PrimaryPart = Hitbox
- Visual:SetPrimaryPartCFrame(TycoonTopLeft * CFrame.new(Vector3.new(-Hitbox.Size.x/2, Hitbox.Size.y/2, -Hitbox.Size.z/2)))
- local TycoonBaseSizeX, TycoonBaseSizeZ
- local HitboxSizeX, HitboxSizeZ
- local Hitboxes
- local NewVector
- local LastPosition = CFrame.new()
- local function VerifyPos()
- local ModelColliding
- local function Argue()
- for i, Hitbox in pairs(Hitboxes) do
- if Hitbox.Name == "Hitbox" and not Hitbox:IsDescendantOf(Visual) then
- return false
- end
- end
- local CheckRay = Ray.new(Visual.Hitbox.Position, Vector3.new(0,-500,0))
- local Hit = workspace:FindPartOnRayWithIgnoreList(CheckRay,{GetTycoon()})
- if Hit and Hit:FindFirstChild("Base") and Hit.Name == GetTycoon().Name then
- return true
- end
- return false
- end
- local ModelColliding = not Argue()
- GoodPlacement = not ModelColliding
- Visual:SetPrimaryPartCFrame(NewVector * CFrame.Angles(0, math.rad(Rotation), 0))
- if GoodPlacement then
- LastPosition = NewVector * CFrame.Angles(0, math.rad(Rotation), 0)
- Visual.Hitbox.BrickColor = BrickColor.new("Bright blue")
- Visual.SelectionBox.Color3 = Color3.new(0.0509804, 0.411765, 0.67451)
- else
- Visual.Hitbox.BrickColor = BrickColor.new("Really red")
- Visual.SelectionBox.Color3 = Color3.new(1,0,0)
- end
- end
- local function CheckPos(xdisp,zdisp,placepos) -- placepos is Mouse.Hit.p on pc
- xdisp = xdisp or 0
- zdisp = zdisp or 0
- if Rotation % 180 == 0 then
- TycoonBaseSizeX, TycoonBaseSizeZ = TycoonBase.Size.x, TycoonBase.Size.z
- HitboxSizeX, HitboxSizeZ = Hitbox.Size.x, Hitbox.Size.z
- else
- TycoonBaseSizeX, TycoonBaseSizeZ = TycoonBase.Size.x, TycoonBase.Size.z
- HitboxSizeX, HitboxSizeZ = Hitbox.Size.z, Hitbox.Size.x
- end
- local TycoonTopLeft = TycoonBase.CFrame * CFrame.new(Vector3.new(TycoonBase.Size.x/2, 0, TycoonBase.Size.z/2))
- local BaseAngleX, BaseAngleY, BaseAngleZ = CFrame.new(TycoonBase.Position, (TycoonBase.CFrame*Vector3.new(1, 0, 0))):toEulerAnglesXYZ()
- local VectorRotation = CFrame.Angles(BaseAngleX, BaseAngleY, BaseAngleZ)
- local RoundByThreeX = RoundByThree(math.floor(placepos.x) + xdisp - math.ceil(TycoonTopLeft.x))
- local RoundByThreeZ = RoundByThree(math.floor(placepos.z) + zdisp - math.ceil(TycoonTopLeft.z))
- if RoundByThreeX < -TycoonBaseSizeX + HitboxSizeX then
- RoundByThreeX = RoundByThreeX + HitboxSizeX
- end
- if RoundByThreeZ < -TycoonBaseSizeZ + HitboxSizeZ then
- RoundByThreeZ = RoundByThreeZ + HitboxSizeZ
- end
- local VectorComponent1 = CFrame.new(Vector3.new(TycoonTopLeft.x, TycoonBase.Position.y, TycoonTopLeft.z))
- local VectorComponent2 = CFrame.new(Vector3.new(RoundByThreeX, TycoonBase.Size.y/2, RoundByThreeZ)) --*VectorRotation
- local VectorComponent3 = CFrame.new(Vector3.new(-HitboxSizeX/2, Hitbox.Size.y/2, -HitboxSizeZ/2))
- NewVector = VectorComponent1*VectorComponent2*VectorComponent3
- local RegionVectorMin = NewVector * CFrame.new(Vector3.new(HitboxSizeX/2, -Hitbox.Size.y/2, HitboxSizeZ/2))
- local RegionVectorMax = NewVector * CFrame.new(-Vector3.new(HitboxSizeX/2, -Hitbox.Size.y/2, HitboxSizeZ/2))
- Hitboxes = game.Workspace:FindPartsInRegion3(
- Region3.new(
- Vector3.new(
- math.min(RegionVectorMin.x, RegionVectorMax.x),
- math.min(RegionVectorMin.y, RegionVectorMax.y),
- math.min(RegionVectorMin.z, RegionVectorMax.z)
- ) + Vector3.new(0.1, 0, 0.1),
- Vector3.new(
- math.max(RegionVectorMin.x, RegionVectorMax.x),
- math.max(RegionVectorMin.y, RegionVectorMax.y),
- math.max(RegionVectorMin.z, RegionVectorMax.z)
- ) - Vector3.new(0.1, 0, 0.1)
- ), game.Workspace.Map, 100
- )
- return true
- end
- while Placing do
- GetTycoon().Base.Grid.Transparency = 0.5
- if TycoonBase ~= nil then
- local UIS = game:GetService("UserInputService")
- if UIS.GamepadEnabled or (UIS.TouchEnabled and not UIS.MouseEnabled) then
- local LookVector = workspace.CurrentCamera.CoordinateFrame.lookVector
- local xCo = 1
- local zCo = 1
- if LookVector.x > 0 then
- xCo = 2
- end
- if LookVector.z > 0 then
- zCo = 2
- end
- NewVector = Vector3.new(LookVector.x * xCo, LookVector.y, LookVector.z * zCo)
- local Pos = Player.Character.HumanoidRootPart.Position + (NewVector * 20)
- -- local Pos = Player.Character.Torso.Position + (NewVector * 20)
- CheckPos(0,0,Pos)
- VerifyPos()
- elseif Mouse ~= nil and Mouse.Target ~= nil and Mouse.Target.Name == GetTycoon().Name and Mouse.Target:FindFirstChild("Base") then
- CheckPos(0,0,Mouse.Hit.p)
- VerifyPos()
- --TransformModel(Visual:GetChildren(), Visual.PrimaryPart.CFrame, CFrame.new(VectorComponent3.p, VectorComponent3*CFrame.new(1, 0, 0)) + CFrame.new(LastPosition.p), true)
- end
- end
- game:GetService("RunService").Heartbeat:wait()
- end
- if Mouse then
- Mouse.TargetFilter = nil
- end
- --RemoveItem:InvokeServer(ItemBtn.ItemId.Value, 1)
- GetTycoon().Base.Grid.Transparency = 1
- --Mouse.Icon = ""
- --game:GetService("UserInputService").MouseIconEnabled = false
- end
- end
- end
- end
- for i = 1, 200 do
- local t = script.Parent.Template:Clone()
- t.Name = tostring(i)
- t.Parent = script.Parent.YYLeft.Inventory.Items.Scroll
- t.Visible = true
- t.MouseEnter:Connect(function()
- t.Icon.Amount.Visible = true
- script.Parent.Sounds.Hover:Play()
- t.Icon:TweenPosition(UDim2.new(0.05,0,0.08,0),"InOut","Quad",0.25,true)
- t.White:TweenPosition(UDim2.new(0,0,0.03,0),"InOut","Quad",0.25,true)
- t.Grey:TweenSizeAndPosition(UDim2.new(1,0,1,0),UDim2.new(0,0,0.03,0),"InOut","Quad",0.25,true)
- if t.ItemId.Value > 0 then
- selectItem(t.ItemId.Value)
- end
- end)
- t.MouseLeave:Connect(function()
- t.Icon.Amount.Visible = false
- t.Icon:TweenPosition(UDim2.new(0.05,0,0.05,0),"InOut","Quad",0.25,true)
- t.White:TweenPosition(UDim2.new(0,0,0,0),"InOut","Quad",0.25,true)
- t.Grey:TweenSizeAndPosition(UDim2.new(1,0,1.03,0),UDim2.new(0,0,0,0),"InOut","Quad",0.25,true)
- end)
- t.MouseButton1Click:connect(function()
- InitiatePlacing(t)
- end)
- end
- local row = 4
- local sizey = 0
- function adjustscrolls()
- local rows = math.ceil(script.Parent.YYLeft.Inventory.Buttons.Value / row)
- script.Parent.YYLeft.Inventory.Items.Scroll.CanvasSize = UDim2.new(0,0,0.1,rows * sizey)
- rows = math.ceil(script.Parent.YYRight.Shop.Buttons.Value / row)
- script.Parent.YYRight.Shop.Items.Scroll.CanvasSize = UDim2.new(0,0,0.1,rows * sizey)
- end
- script.Parent.YYLeft.Inventory.Buttons.Changed:connect(adjustscrolls)
- script.Parent.YYRight.Shop.Buttons.Changed:connect(adjustscrolls)
- function adjust()
- local y = script.Parent.ScreenRes.AbsoluteSize.Y
- local x = script.Parent.ScreenRes.AbsoluteSize.X
- local yx = y/x
- if y < 400 then
- script.Parent.YYLButtons.Size = UDim2.new(1.4,0,1.4,0)
- script.Parent.YYLButtons.Position = UDim2.new(0,0,-0.2,0)
- script.Parent.YYRButtons.Size = UDim2.new(1.4,0,1.4,0)
- script.Parent.YYRButtons.Position = UDim2.new(1,0,-0.2,0)
- script.Parent.YYBottom.Size = UDim2.new(1.4,0,1.4,0)
- script.Parent.YYBottom.Position = UDim2.new(1,0,-0.4,0)
- script.Parent.YYTop.Size = UDim2.new(1.4,0,1.4,0)
- script.Parent.YYTop.Position = UDim2.new(0.5,0,0,0)
- elseif y < 700 then
- script.Parent.YYLButtons.Size = UDim2.new(1,0,1,0)
- script.Parent.YYLButtons.Position = UDim2.new(0,0,0,0)
- script.Parent.YYRButtons.Size = UDim2.new(1,0,1,0)
- script.Parent.YYRButtons.Position = UDim2.new(1,0,0,0)
- script.Parent.YYBottom.Size = UDim2.new(1,0,1,0)
- script.Parent.YYBottom.Position = UDim2.new(1,0,0,0)
- script.Parent.YYTop.Size = UDim2.new(1,0,1,0)
- script.Parent.YYTop.Position = UDim2.new(.5,0,0,0)
- else
- script.Parent.YYLButtons.Size = UDim2.new(0,900,0,900)
- script.Parent.YYLButtons.Position = UDim2.new(0,0,0.5,-450)
- script.Parent.YYRButtons.Size = UDim2.new(0,900,0,900)
- script.Parent.YYRButtons.Position = UDim2.new(1,0,1,-900)
- script.Parent.YYBottom.Size = UDim2.new(0,900,0,900)
- script.Parent.YYBottom.Position = UDim2.new(1,0,1,-900)
- script.Parent.YYTop.Size = UDim2.new(0,900,0,900)
- script.Parent.YYTop.Position = UDim2.new(0.5,0,0,0)
- end
- if y < 1000 then
- script.Parent.YYCenter.Size = UDim2.new(1,0,1,0)
- script.Parent.YYCenter.Position = UDim2.new(0.5,0,0,0)
- else
- script.Parent.YYCenter.Size = UDim2.new(0,1000,0,1000)
- script.Parent.YYCenter.Position = UDim2.new(0.5,0,0.5,-500)
- end
- if y < 600 then
- row = 3
- elseif y < 800 then
- row = 4
- else
- row = 5
- end
- if yx > .55 and row == 5 then
- row = 4
- end
- local num = #script.Parent.YYLeft.Inventory.Items.Scroll:GetChildren()
- local width = (.975 - .01 * row ) / row
- local len = nil
- local i = 0
- for a = 1, num do
- i = i + 1
- local gui = script.Parent.YYLeft.Inventory.Items.Scroll[i]
- gui.Size = UDim2.new(width,0,width,0)
- local e = i - 1
- local rw = 0
- if i > row then
- e = ( i - 1 ) % row
- rw = math.floor((i-1)/row)
- end
- local height = gui.Difference.AbsoluteSize.X
- sizey = height
- gui.Position = UDim2.new(.01 + (width + .01) * e,0,0, height * rw)
- end
- local num = #script.Parent.YYRight.Shop.Items.Scroll:GetChildren()
- local width = (.975 - .01 * row ) / row
- local len = nil
- local i = 0
- for a = 1, num do
- i = i + 1
- local gui = script.Parent.YYRight.Shop.Items.Scroll[i]
- gui.Size = UDim2.new(width,0,width,0)
- local e = i - 1
- local rw = 0
- if i > row then
- e = ( i - 1 ) % row
- rw = math.floor((i-1)/row)
- end
- local height = gui.Difference.AbsoluteSize.X
- gui.Position = UDim2.new(.01 + (width + .01) * e,0,0, height * rw)
- end
- adjustscrolls()
- if yx > .67 then
- script.Parent.YYLeft.Position = UDim2.new(-0.05,0,0,0)
- script.Parent.YYRight.Position = UDim2.new(1.05,0,0,0)
- script.Parent.YYLeft.Inventory.Items.Size = UDim2.new(0.49,0,1,0)
- script.Parent.YYLeft.Inventory.Search.Position = UDim2.new(0.15,0,0.015,0)
- script.Parent.YYLeft.Inventory.Select.Labels.Visible = false
- script.Parent.YYLeft.Inventory.Select.Position = UDim2.new(-0.025,0,0.015,0)
- script.Parent.YYLeft.Inventory.Selected.Position = UDim2.new(0.5,0,0,0)
- script.Parent.YYRight.Shop.Items.Size = UDim2.new(0.49,0,1,0)
- script.Parent.YYRight.Shop.Items.Position = UDim2.new(0.51,0,0,0)
- script.Parent.YYRight.Shop.Top.Size = UDim2.new(0.55,0,0.1,0)
- script.Parent.YYRight.Shop.Top.Position = UDim2.new(0.51,0,0.025,0)
- script.Parent.YYRight.Shop.Selected.Position = UDim2.new(0.2,0,0,0)
- elseif yx > .6 then
- script.Parent.YYLeft.Position = UDim2.new(0,0,0,0)
- script.Parent.YYRight.Position = UDim2.new(1,0,0,0)
- script.Parent.YYLeft.Inventory.Items.Size = UDim2.new(0.49,0,1,0)
- script.Parent.YYLeft.Inventory.Search.Position = UDim2.new(0.15,0,0.015,0)
- script.Parent.YYLeft.Inventory.Select.Labels.Visible = false
- script.Parent.YYLeft.Inventory.Select.Position = UDim2.new(-0.025,0,0.015,0)
- script.Parent.YYLeft.Inventory.Selected.Position = UDim2.new(0.5,0,0,0)
- script.Parent.YYRight.Shop.Items.Size = UDim2.new(0.49,0,1,0)
- script.Parent.YYRight.Shop.Items.Position = UDim2.new(0.51,0,0,0)
- script.Parent.YYRight.Shop.Top.Size = UDim2.new(0.55,0,0.1,0)
- script.Parent.YYRight.Shop.Top.Position = UDim2.new(0.51,0,0.025,0)
- script.Parent.YYRight.Shop.Selected.Position = UDim2.new(0.2,0,0,0)
- elseif yx > .55 then
- script.Parent.YYLeft.Position = UDim2.new(0,0,0,0)
- script.Parent.YYRight.Position = UDim2.new(1,0,0,0)
- script.Parent.YYLeft.Inventory.Items.Size = UDim2.new(0.59,0,1,0)
- script.Parent.YYLeft.Inventory.Search.Position = UDim2.new(0.25,0,0.015,0)
- script.Parent.YYLeft.Inventory.Select.Labels.Visible = false
- script.Parent.YYLeft.Inventory.Select.Position = UDim2.new(0.025,0,0.015,0)
- script.Parent.YYLeft.Inventory.Selected.Position = UDim2.new(0.6,0,0,0)
- script.Parent.YYRight.Shop.Items.Size = UDim2.new(0.59,0,1,0)
- script.Parent.YYRight.Shop.Items.Position = UDim2.new(0.41,0,0,0)
- script.Parent.YYRight.Shop.Top.Size = UDim2.new(0.69,0,0.125,0)
- script.Parent.YYRight.Shop.Top.Position = UDim2.new(0.41,0,0,0)
- script.Parent.YYRight.Shop.Selected.Position = UDim2.new(0.1,0,0,0)
- else
- script.Parent.YYLeft.Position = UDim2.new(0,0,0,0)
- script.Parent.YYRight.Position = UDim2.new(1,0,0,0)
- script.Parent.YYLeft.Inventory.Items.Size = UDim2.new(0.69,0,1,0)
- script.Parent.YYLeft.Inventory.Search.Position = UDim2.new(0.325,0,0.015,0)
- script.Parent.YYLeft.Inventory.Select.Labels.Visible = true
- script.Parent.YYLeft.Inventory.Select.Position = UDim2.new(0.05,0,0.015,0)
- script.Parent.YYLeft.Inventory.Selected.Position = UDim2.new(0.7,0,0,0)
- script.Parent.YYRight.Shop.Items.Size = UDim2.new(0.69,0,1,0)
- script.Parent.YYRight.Shop.Items.Position = UDim2.new(0.31,0,0,0)
- script.Parent.YYRight.Shop.Top.Size = UDim2.new(0.69,0,0.125,0)
- script.Parent.YYRight.Shop.Top.Position = UDim2.new(0.31,0,0,0)
- script.Parent.YYRight.Shop.Selected.Position = UDim2.new(0,0,0,0)
- end
- end
- adjust()
- spawn(function()
- -- roblox doesn't seem to always get the resolution correctly for a very short period, but this should work around that:
- -- (i may be wrong, and in that case, feel free to get rid of it)
- wait (.5)
- adjust()
- wait (.5)
- adjust()
- end)
- script.Parent.ScreenRes.Changed:Connect(function()
- game:GetService("RunService").Heartbeat:wait()
- adjust()
- end)
- function SetButtonImage(Button)
- if Button.ItemId.Value ~= -1 then
- local Item = getItemById(Button.ItemId.Value)
- if Item ~= nil then
- Button.Icon.Image = "http://roblox.com/asset?id=" .. Item.ThumbnailId.Value
- local Tier = game.ReplicatedStorage.Tiers:FindFirstChild(Item.Tier.Value)
- if Tier ~= nil then
- if (Item.Tier.Value == 40 or Item.Tier.Value == 41 or Item.Tier.Value == 30 or Item.Tier.Value == 31 or Item.Tier.Value == 99 or Item.Tier.Value == 78) then
- setColor(Button.White, Tier.TierBackground.Value)
- else
- setColor(Button.White, Color3.new(225/255, 225/255, 225/255))
- end
- --[[
- Button.Tier.Visible = true
- Button.BackgroundColor3 = Tier.TierColor.Value
- Button.Tier.Text = string.sub(Tier.TierName.Value,1,1)
- Button.Tier.TextColor3 = Tier.TierColor.Value
- ]]
- else
- -- Button.Tier.Visible = false
- end
- end
- else
- Button.Icon.Image = ""
- end
- end
- function RefreshInventory()
- local Index = 0
- local Inventory = game.ReplicatedStorage.FetchInventory:InvokeServer()
- local Count = 0
- local Term
- local Search = script.Parent.YYLeft.Inventory.Search.TextBox.Text
- if string.len(Search) > 0 then
- Term = string.lower(Search)
- end
- if Term == "search..." or Term == "search.." or Term == "search." or Term == "search" or Term == " " or Term == " " then
- Term = nil
- end
- local InclItems
- if Term == nil then
- InclItems = game.ReplicatedStorage.Items:GetChildren()
- script.Parent.YYLeft.Inventory.Search.TextBox.Cancel.Visible = false
- else
- script.Parent.YYLeft.Inventory.Search.TextBox.Cancel.Visible = true
- InclItems = {}
- for i,Item in pairs(game.ReplicatedStorage.Items:GetChildren()) do
- local Tier = game.ReplicatedStorage.Tiers:FindFirstChild(tostring(Item.Tier.Value))
- if string.find(string.lower(Item.Name),Term) ~= nil or string.find(string.lower(Tier.TierName.Value),Term) ~= nil or (tonumber(Term) ~= nil and tonumber(Term) == Item.ItemType.Value) then
- InclItems[Item.ItemId.Value] = true
- else
- InclItems[Item.ItemId.Value] = false
- end
- end
- end
- for i,v in pairs(script.Parent.YYLeft.Inventory.Items.Scroll:GetChildren()) do
- repeat Index = Index + 1 until (Index > #game.ReplicatedStorage.Items:GetChildren()) or (Inventory[Index].Quantity and Inventory[Index].Quantity > -1 and InclItems[Index])
- if not (Index > #game.ReplicatedStorage.Items:GetChildren()) then
- v.ItemId.Value = Index
- v.Visible = true
- v.Icon.Amount.Text = Inventory[Index].Quantity
- SetButtonImage(v)
- Count = Count + 1
- else
- v.ItemId.Value = -1
- v.Visible = false
- end
- end
- script.Parent.YYLeft.Inventory.Buttons.Value = Count
- end
- RefreshInventory()
- game.ReplicatedStorage.InventoryChanged.OnClientEvent:connect(RefreshInventory)
- script.Parent.YYLeft.Inventory.Search.TextBox.Cancel.MouseButton1Click:connect(function()
- script.Parent.YYLeft.Inventory.Search.TextBox.Text = "Search..."
- end)
- script.Parent.YYLeft.Inventory.Search.TextBox.Changed:connect(function(Property)
- if Property == "Text" then
- RefreshInventory()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement