This commit is contained in:
watrabi
2025-09-18 17:55:52 -04:00
commit 977f1ff4b8
15030 changed files with 17324420 additions and 0 deletions
@@ -0,0 +1,851 @@
-- This script creates almost all gui elements found in the backpack (warning: there are a lot!)
-- TODO: automate this process
local gui = script.Parent
-- A couple of necessary functions
local function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
print('(BPBuilder): Waiting for ...', instance, name)
instance.ChildAdded:wait()
end
end
local function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
end
end
local function IsTouchDevice()
local touchEnabled = false
pcall(function() touchEnabled = Game:GetService('UserInputService').TouchEnabled end)
return touchEnabled
end
local function IsPhone()
if gui.AbsoluteSize.Y <= 320 then
return true
end
return false
end
waitForChild(game,"Players")
waitForProperty(game.Players,"LocalPlayer")
local player = game.Players.LocalPlayer
-- First up is the current loadout
local CurrentLoadout = Instance.new("Frame")
CurrentLoadout.Name = "CurrentLoadout"
CurrentLoadout.Position = UDim2.new(0.5, -300, 1, -85)
CurrentLoadout.Size = UDim2.new(0, 600, 0, 54)
CurrentLoadout.BackgroundTransparency = 1
CurrentLoadout.RobloxLocked = true
CurrentLoadout.Parent = gui
local CLBackground = Instance.new('ImageLabel')
CLBackground.Name = 'Background';
CLBackground.Size = UDim2.new(1.2, 0, 1.2, 0);
CLBackground.Image = "http://www.watrbx.wtf/asset/?id=23"
CLBackground.BackgroundTransparency = 1.0;
CLBackground.Position = UDim2.new(-0.1, 0, -0.1, 0);
CLBackground.ZIndex = 0.0;
CLBackground.Parent = CurrentLoadout
CLBackground.Visible = false
local BackgroundUp = Instance.new('ImageLabel')
BackgroundUp.Size = UDim2.new(1, 0, 0.025, 1)
BackgroundUp.Position = UDim2.new(0, 0, 0, 0)
BackgroundUp.Image = 'http://www.watrbx.wtf/asset/?id=24'
BackgroundUp.BackgroundTransparency = 1.0
BackgroundUp.Parent = CLBackground
local Debounce = Instance.new("BoolValue")
Debounce.Name = "Debounce"
Debounce.RobloxLocked = true
Debounce.Parent = CurrentLoadout
local BackpackButton = Instance.new("ImageButton")
BackpackButton.RobloxLocked = true
BackpackButton.Visible = false
BackpackButton.Name = "BackpackButton"
BackpackButton.BackgroundTransparency = 1
BackpackButton.Image = "http://www.watrbx.wtf/asset/?id=21"
BackpackButton.Position = UDim2.new(0.5, -60, 1, -108)
BackpackButton.Size = UDim2.new(0, 120, 0, 18)
waitForChild(gui,"ControlFrame")
BackpackButton.Parent = gui.ControlFrame
local NumSlots = 9
if IsPhone() then
NumSlots = 3
CurrentLoadout.Size = UDim2.new(0, 180, 0, 54)
CurrentLoadout.Position = UDim2.new(0.5, -90, 1, -85)
end
for i = 0, NumSlots do
local slotFrame = Instance.new("Frame")
slotFrame.RobloxLocked = true
slotFrame.BackgroundColor3 = Color3.new(0,0,0)
slotFrame.BackgroundTransparency = 1
slotFrame.BorderColor3 = Color3.new(1, 1, 1)
slotFrame.Name = "Slot" .. tostring(i)
slotFrame.ZIndex = 4.0
if i == 0 then
slotFrame.Position = UDim2.new(0.9, 0, 0, 0)
else
slotFrame.Position = UDim2.new((i - 1) * 0.1, (i-1)* 6,0,0)
end
slotFrame.Size = UDim2.new(0, 54, 1, 0)
slotFrame.Parent = CurrentLoadout
if gui.AbsoluteSize.Y <= 320 then
slotFrame.Position = UDim2.new(0, (i-1)* 60, 0, -50)
print('Well got here', slotFrame, slotFrame.Position.X.Scale, slotFrame.Position.X.Offset)
end
if gui.AbsoluteSize.Y <= 320 and i == 0 then
slotFrame:Destroy()
end
end
local TempSlot = Instance.new("ImageButton")
TempSlot.Name = "TempSlot"
TempSlot.Active = true
TempSlot.Size = UDim2.new(1,0,1,0)
TempSlot.BackgroundTransparency = 1.0
TempSlot.Style = 'Custom'
TempSlot.Visible = false
TempSlot.RobloxLocked = true
TempSlot.Parent = CurrentLoadout
TempSlot.ZIndex = 4.0
local slotBackground = Instance.new('ImageLabel')
slotBackground.Name = 'Background'
slotBackground.BackgroundTransparency = 1.0
slotBackground.Image = 'http://www.watrbx.wtf/asset/?id=25'
slotBackground.Size = UDim2.new(1, 0, 1, 0)
slotBackground.Parent = TempSlot
local HighLight = Instance.new('ImageLabel')
HighLight.Name = 'Highlight'
HighLight.BackgroundTransparency = 1.0
HighLight.Image = 'http://www.watrbx.wtf/asset/?id=26'
HighLight.Size = UDim2.new(1, 0, 1, 0)
--HighLight.Parent = TempSlot
HighLight.Visible = false
-- TempSlot Children
local GearReference = Instance.new("ObjectValue")
GearReference.Name = "GearReference"
GearReference.RobloxLocked = true
GearReference.Parent = TempSlot
local ToolTipLabel = Instance.new("TextLabel")
ToolTipLabel.Name = "ToolTipLabel"
ToolTipLabel.RobloxLocked = true
ToolTipLabel.Text = ""
ToolTipLabel.BackgroundTransparency = 0.5
ToolTipLabel.BorderSizePixel = 0
ToolTipLabel.Visible = false
ToolTipLabel.TextColor3 = Color3.new(1,1,1)
ToolTipLabel.BackgroundColor3 = Color3.new(0,0,0)
ToolTipLabel.TextStrokeTransparency = 0
ToolTipLabel.Font = Enum.Font.ArialBold
ToolTipLabel.FontSize = Enum.FontSize.Size14
--ToolTipLabel.TextWrap = true
ToolTipLabel.Size = UDim2.new(1,60,0,20)
ToolTipLabel.Position = UDim2.new(0,-30,0,-30)
ToolTipLabel.Parent = TempSlot
local Kill = Instance.new("BoolValue")
Kill.Name = "Kill"
Kill.RobloxLocked = true
Kill.Parent = TempSlot
local GearImage = Instance.new("ImageLabel")
GearImage.Name = "GearImage"
GearImage.BackgroundTransparency = 1
GearImage.Position = UDim2.new(0, 0, 0, 0)
GearImage.Size = UDim2.new(1, 0, 1, 0)
GearImage.ZIndex = 5.0
GearImage.RobloxLocked = true
GearImage.Parent = TempSlot
local SlotNumber = Instance.new("TextLabel")
SlotNumber.Name = "SlotNumber"
SlotNumber.BackgroundTransparency = 1
SlotNumber.BorderSizePixel = 0
SlotNumber.Font = Enum.Font.ArialBold
SlotNumber.FontSize = Enum.FontSize.Size18
SlotNumber.Position = UDim2.new(0, 0, 0, 0)
SlotNumber.Size = UDim2.new(0,10,0,15)
SlotNumber.TextColor3 = Color3.new(1,1,1)
SlotNumber.TextTransparency = 0
SlotNumber.TextXAlignment = Enum.TextXAlignment.Left
SlotNumber.TextYAlignment = Enum.TextYAlignment.Bottom
SlotNumber.RobloxLocked = true
SlotNumber.Parent = TempSlot
SlotNumber.ZIndex = 5
if IsTouchDevice() then
SlotNumber.Visible = false
end
local SlotNumberDownShadow = SlotNumber:Clone()
SlotNumberDownShadow.Name = "SlotNumberDownShadow"
SlotNumberDownShadow.TextColor3 = Color3.new(0,0,0)
SlotNumberDownShadow.Position = UDim2.new(0, 1, 0, -1)
SlotNumberDownShadow.Parent = TempSlot
SlotNumberDownShadow.ZIndex = 2
local SlotNumberUpShadow = SlotNumberDownShadow:Clone()
SlotNumberUpShadow.Name = "SlotNumberUpShadow"
SlotNumberUpShadow.Position = UDim2.new(0, -1, 0, -1)
SlotNumberUpShadow.Parent = TempSlot
local GearText = Instance.new("TextLabel")
GearText.RobloxLocked = true
GearText.Name = "GearText"
GearText.BackgroundTransparency = 1
GearText.Font = Enum.Font.Arial
GearText.FontSize = Enum.FontSize.Size14
GearText.Position = UDim2.new(0,-8,0,-8)
GearText.Size = UDim2.new(1,16,1,16)
GearText.Text = ""
GearText.TextColor3 = Color3.new(1,1,1)
GearText.TextWrap = true
GearText.Parent = TempSlot
GearText.ZIndex = 5.0
--- Great, now lets make the inventory!
local Backpack = Instance.new("Frame")
Backpack.RobloxLocked = true
Backpack.Visible = false
Backpack.Name = "Backpack"
Backpack.Position = UDim2.new(0.5, 0, 0.5, 0)
Backpack.BackgroundColor3 = Color3.new(32/255, 32/255, 32/255)
Backpack.BackgroundTransparency = 0.0
Backpack.BorderSizePixel = 0
Backpack.Parent = gui
Backpack.Active = true
-- Backpack Children
local SwapSlot = Instance.new("BoolValue")
SwapSlot.RobloxLocked = true
SwapSlot.Name = "SwapSlot"
SwapSlot.Parent = Backpack
-- SwapSlot Children
local Slot = Instance.new("IntValue")
Slot.RobloxLocked = true
Slot.Name = "Slot"
Slot.Parent = SwapSlot
local GearButton = Instance.new("ObjectValue")
GearButton.RobloxLocked = true
GearButton.Name = "GearButton"
GearButton.Parent = SwapSlot
local Tabs = Instance.new("Frame")
Tabs.Name = "Tabs"
Tabs.Visible = false
Tabs.Active = false
Tabs.RobloxLocked = true
Tabs.BackgroundColor3 = Color3.new(0,0,0)
Tabs.BackgroundTransparency = 0.08
Tabs.BorderSizePixel = 0
Tabs.Position = UDim2.new(0,0,-0.1,-4)
Tabs.Size = UDim2.new(1,0,0.1,4)
Tabs.Parent = Backpack
-- Tabs Children
local tabLine = Instance.new("Frame")
tabLine.RobloxLocked = true
tabLine.Name = "TabLine"
tabLine.BackgroundColor3 = Color3.new(53/255, 53/255, 53/255)
tabLine.BorderSizePixel = 0
tabLine.Position = UDim2.new(0,5,1,-4)
tabLine.Size = UDim2.new(1,-10,0,4)
tabLine.ZIndex = 2
tabLine.Parent = Tabs
local InventoryButton = Instance.new("TextButton")
InventoryButton.RobloxLocked = true
InventoryButton.Name = "InventoryButton"
InventoryButton.Size = UDim2.new(0,60,0,30)
InventoryButton.Position = UDim2.new(0,7,1,-31)
InventoryButton.BackgroundColor3 = Color3.new(1,1,1)
InventoryButton.BorderColor3 = Color3.new(1,1,1)
InventoryButton.Font = Enum.Font.ArialBold
InventoryButton.FontSize = Enum.FontSize.Size18
InventoryButton.Text = "Gear"
InventoryButton.AutoButtonColor = false
InventoryButton.TextColor3 = Color3.new(0,0,0)
InventoryButton.Selected = true
InventoryButton.Active = true
InventoryButton.ZIndex = 3
InventoryButton.Parent = Tabs
local closeButton = Instance.new("TextButton")
closeButton.RobloxLocked = true
closeButton.Name = "CloseButton"
closeButton.Font = Enum.Font.ArialBold
closeButton.FontSize = Enum.FontSize.Size24
closeButton.Position = UDim2.new(1,-33,0,4)
closeButton.Size = UDim2.new(0,30,0,30)
closeButton.Style = Enum.ButtonStyle.RobloxButton
closeButton.Text = ""
closeButton.TextColor3 = Color3.new(1,1,1)
closeButton.Parent = Tabs
closeButton.Modal = true
--closeButton child
local XImage = Instance.new("ImageLabel")
XImage.RobloxLocked = true
XImage.Name = "XImage"
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf/asset/?id=27")
XImage.Image = "http://www.watrbx.wtf/asset/?id=27" --TODO: move to rbxasset
XImage.BackgroundTransparency = 1
XImage.Position = UDim2.new(-.25,-1,-.25,-1)
XImage.Size = UDim2.new(1.5,2,1.5,2)
XImage.ZIndex = 2
XImage.Parent = closeButton
-- Generic Search gui used across backpack
local SearchFrame = Instance.new("Frame")
SearchFrame.RobloxLocked = true
SearchFrame.Name = "SearchFrame"
SearchFrame.BackgroundTransparency = 1
SearchFrame.Position = UDim2.new(1,-220,0,2)
SearchFrame.Size = UDim2.new(0,220,0,24)
SearchFrame.Parent = Backpack
-- SearchFrame Children
local SearchButton = Instance.new("ImageButton")
SearchButton.RobloxLocked = true
SearchButton.Name = "SearchButton"
SearchButton.Size = UDim2.new(0,25,0,25)
SearchButton.BackgroundTransparency = 1
SearchButton.Image = "rbxasset://textures/ui/SearchIcon.png"
SearchButton.Parent = SearchFrame
local SearchBoxFrame = Instance.new("TextButton")
SearchBoxFrame.RobloxLocked = true
SearchBoxFrame.Position = UDim2.new(0,25,0,0)
SearchBoxFrame.Size = UDim2.new(1,-28,0,26)
SearchBoxFrame.Name = "SearchBoxFrame"
SearchBoxFrame.Text = ""
SearchBoxFrame.Style = Enum.ButtonStyle.RobloxButton
SearchBoxFrame.Parent = SearchFrame
-- SearchBoxFrame Children
local SearchBox = Instance.new("TextBox")
SearchBox.RobloxLocked = true
SearchBox.Name = "SearchBox"
SearchBox.BackgroundTransparency = 1
SearchBox.Font = Enum.Font.ArialBold
SearchBox.FontSize = Enum.FontSize.Size12
SearchBox.Position = UDim2.new(0,-5,0,-5)
SearchBox.Size = UDim2.new(1,10,1,10)
SearchBox.TextColor3 = Color3.new(1,1,1)
SearchBox.TextXAlignment = Enum.TextXAlignment.Left
SearchBox.ZIndex = 2
SearchBox.TextWrap = true
SearchBox.Text = "Search..."
SearchBox.Parent = SearchBoxFrame
local ResetButton = Instance.new("TextButton")
ResetButton.RobloxLocked = true
ResetButton.Visible = false
ResetButton.Name = "ResetButton"
ResetButton.Position = UDim2.new(1,-26,0,3)
ResetButton.Size = UDim2.new(0,20,0,20)
ResetButton.Style = Enum.ButtonStyle.RobloxButtonDefault
ResetButton.Text = "X"
ResetButton.TextColor3 = Color3.new(1,1,1)
ResetButton.Font = Enum.Font.ArialBold
ResetButton.FontSize = Enum.FontSize.Size18
ResetButton.ZIndex = 3
ResetButton.Parent = SearchFrame
------------------------------- GEAR -------------------------------------------------------
local Gear = Instance.new("Frame")
Gear.Name = "Gear"
Gear.RobloxLocked = true
Gear.BackgroundTransparency = 1
Gear.Size = UDim2.new(1,0,1,0)
Gear.Parent = Backpack
-- Gear Children
local AssetsList = Instance.new("Frame")
AssetsList.RobloxLocked = true
AssetsList.Name = "AssetsList"
AssetsList.BackgroundTransparency = 1
AssetsList.Size = UDim2.new(0.2,0,1,0)
AssetsList.Style = Enum.FrameStyle.RobloxSquare
AssetsList.Visible = false
AssetsList.Parent = Gear
local GearGrid = Instance.new("Frame")
GearGrid.RobloxLocked = true
GearGrid.Name = "GearGrid"
GearGrid.Size = UDim2.new(0.95, 0, 1, 0)
GearGrid.BackgroundTransparency = 1
GearGrid.Parent = Gear
local GearButton = Instance.new("ImageButton")
GearButton.RobloxLocked = true
GearButton.Visible = false
GearButton.Name = "GearButton"
GearButton.Size = UDim2.new(0, 54, 0, 54)
GearButton.Style = 'Custom'
GearButton.Parent = GearGrid
GearButton.BackgroundTransparency = 1.0
local slotBackground = Instance.new('ImageLabel')
slotBackground.Name = 'Background'
slotBackground.BackgroundTransparency = 1.0
slotBackground.Image = 'http://www.watrbx.wtf/asset/?id=25'
slotBackground.Size = UDim2.new(1, 0, 1, 0)
slotBackground.Parent = GearButton
-- GearButton Children
local GearReference = Instance.new("ObjectValue")
GearReference.RobloxLocked = true
GearReference.Name = "GearReference"
GearReference.Parent = GearButton
local GreyOutButton = Instance.new("Frame")
GreyOutButton.RobloxLocked = true
GreyOutButton.Name = "GreyOutButton"
GreyOutButton.BackgroundTransparency = 0.5
GreyOutButton.Size = UDim2.new(1,0,1,0)
GreyOutButton.Active = true
GreyOutButton.Visible = false
GreyOutButton.ZIndex = 3
GreyOutButton.Parent = GearButton
local GearText = Instance.new("TextLabel")
GearText.RobloxLocked = true
GearText.Name = "GearText"
GearText.BackgroundTransparency = 1
GearText.Font = Enum.Font.Arial
GearText.FontSize = Enum.FontSize.Size14
GearText.Position = UDim2.new(0,-8,0,-8)
GearText.Size = UDim2.new(1,16,1,16)
GearText.Text = ""
GearText.ZIndex = 2
GearText.TextColor3 = Color3.new(1,1,1)
GearText.TextWrap = true
GearText.Parent = GearButton
local GearGridScrollingArea = Instance.new("Frame")
GearGridScrollingArea.RobloxLocked = true
GearGridScrollingArea.Name = "GearGridScrollingArea"
GearGridScrollingArea.Position = UDim2.new(1, -19, 0, 35)
GearGridScrollingArea.Size = UDim2.new(0, 17, 1, -45)
GearGridScrollingArea.BackgroundTransparency = 1
GearGridScrollingArea.Parent = Gear
local GearLoadouts = Instance.new("Frame")
GearLoadouts.RobloxLocked = true
GearLoadouts.Name = "GearLoadouts"
GearLoadouts.BackgroundTransparency = 1
GearLoadouts.Position = UDim2.new(0.7,23,0.5,1)
GearLoadouts.Size = UDim2.new(0.3,-23,0.5,-1)
GearLoadouts.Parent = Gear
GearLoadouts.Visible = false
-- GearLoadouts Children
local GearLoadoutsHeader = Instance.new("Frame")
GearLoadoutsHeader.RobloxLocked = true
GearLoadoutsHeader.Name = "GearLoadoutsHeader"
GearLoadoutsHeader.BackgroundColor3 = Color3.new(0,0,0)
GearLoadoutsHeader.BackgroundTransparency = 0.2
GearLoadoutsHeader.BorderColor3 = Color3.new(1,0,0)
GearLoadoutsHeader.Size = UDim2.new(1,2,0.15,-1)
GearLoadoutsHeader.Parent = GearLoadouts
-- GearLoadoutsHeader Children
local LoadoutsHeaderText = Instance.new("TextLabel")
LoadoutsHeaderText.RobloxLocked = true
LoadoutsHeaderText.Name = "LoadoutsHeaderText"
LoadoutsHeaderText.BackgroundTransparency = 1
LoadoutsHeaderText.Font = Enum.Font.ArialBold
LoadoutsHeaderText.FontSize = Enum.FontSize.Size18
LoadoutsHeaderText.Size = UDim2.new(1,0,1,0)
LoadoutsHeaderText.Text = "Loadouts"
LoadoutsHeaderText.TextColor3 = Color3.new(1,1,1)
LoadoutsHeaderText.Parent = GearLoadoutsHeader
local GearLoadoutsScrollingArea = GearGridScrollingArea:clone()
GearLoadoutsScrollingArea.RobloxLocked = true
GearLoadoutsScrollingArea.Name = "GearLoadoutsScrollingArea"
GearLoadoutsScrollingArea.Position = UDim2.new(1,-15,0.15,2)
GearLoadoutsScrollingArea.Size = UDim2.new(0,17,0.85,-2)
GearLoadoutsScrollingArea.Parent = GearLoadouts
local LoadoutsList = Instance.new("Frame")
LoadoutsList.RobloxLocked = true
LoadoutsList.Name = "LoadoutsList"
LoadoutsList.Position = UDim2.new(0,0,0.15,2)
LoadoutsList.Size = UDim2.new(1,-17,0.85,-2)
LoadoutsList.Style = Enum.FrameStyle.RobloxSquare
LoadoutsList.Parent = GearLoadouts
local GearPreview = Instance.new("Frame")
GearPreview.RobloxLocked = true
GearPreview.Name = "GearPreview"
GearPreview.Position = UDim2.new(0.7,23,0,0)
GearPreview.Size = UDim2.new(0.3,-28,0.5,-1)
GearPreview.BackgroundTransparency = 1
GearPreview.ZIndex = 7
GearPreview.Parent = Gear
-- GearPreview Children
local GearStats = Instance.new("Frame")
GearStats.RobloxLocked = true
GearStats.Name = "GearStats"
GearStats.BackgroundTransparency = 1
GearStats.Position = UDim2.new(0,0,0.75,0)
GearStats.Size = UDim2.new(1,0,0.25,0)
GearStats.ZIndex = 8
GearStats.Parent = GearPreview
-- GearStats Children
local GearName = Instance.new("TextLabel")
GearName.RobloxLocked = true
GearName.Name = "GearName"
GearName.BackgroundTransparency = 1
GearName.Font = Enum.Font.ArialBold
GearName.FontSize = Enum.FontSize.Size18
GearName.Position = UDim2.new(0,-3,0,0)
GearName.Size = UDim2.new(1,6,1,5)
GearName.Text = ""
GearName.TextColor3 = Color3.new(1,1,1)
GearName.TextWrap = true
GearName.ZIndex = 9
GearName.Parent = GearStats
local GearImage = Instance.new("ImageLabel")
GearImage.RobloxLocked = true
GearImage.Name = "GearImage"
GearImage.Image = ""
GearImage.BackgroundTransparency = 1
GearImage.Position = UDim2.new(0.125,0,0,0)
GearImage.Size = UDim2.new(0.75,0,0.75,0)
GearImage.ZIndex = 8
GearImage.Parent = GearPreview
--GearImage Children
local GearIcons = Instance.new("Frame")
GearIcons.BackgroundColor3 = Color3.new(0,0,0)
GearIcons.BackgroundTransparency = 0.5
GearIcons.BorderSizePixel = 0
GearIcons.RobloxLocked = true
GearIcons.Name = "GearIcons"
GearIcons.Position = UDim2.new(0.4,2,0.85,-2)
GearIcons.Size = UDim2.new(0.6,0,0.15,0)
GearIcons.Visible = false
GearIcons.ZIndex = 9
GearIcons.Parent = GearImage
-- GearIcons Children
local GenreImage = Instance.new("ImageLabel")
GenreImage.RobloxLocked = true
GenreImage.Name = "GenreImage"
GenreImage.BackgroundColor3 = Color3.new(102/255,153/255,1)
GenreImage.BackgroundTransparency = 0.5
GenreImage.BorderSizePixel = 0
GenreImage.Size = UDim2.new(0.25,0,1,0)
GenreImage.Parent = GearIcons
local AttributeOneImage = GenreImage:clone()
AttributeOneImage.RobloxLocked = true
AttributeOneImage.Name = "AttributeOneImage"
AttributeOneImage.BackgroundColor3 = Color3.new(1,51/255,0)
AttributeOneImage.Position = UDim2.new(0.25,0,0,0)
AttributeOneImage.Parent = GearIcons
local AttributeTwoImage = GenreImage:clone()
AttributeTwoImage.RobloxLocked = true
AttributeTwoImage.Name = "AttributeTwoImage"
AttributeTwoImage.BackgroundColor3 = Color3.new(153/255,1,153/255)
AttributeTwoImage.Position = UDim2.new(0.5,0,0,0)
AttributeTwoImage.Parent = GearIcons
local AttributeThreeImage = GenreImage:clone()
AttributeThreeImage.RobloxLocked = true
AttributeThreeImage.Name = "AttributeThreeImage"
AttributeThreeImage.BackgroundColor3 = Color3.new(0,0.5,0.5)
AttributeThreeImage.Position = UDim2.new(0.75,0,0,0)
AttributeThreeImage.Parent = GearIcons
------------------------------- WARDROBE -------------------------------------------------------
local function makeCharFrame(frameName, parent)
local frame = Instance.new("Frame")
frame.RobloxLocked = true
frame.Size = UDim2.new(1,0,1,-70)
frame.Position = UDim2.new(0,0,0,20)
frame.Name = frameName
frame.BackgroundTransparency = 1
frame.Parent = parent
frame.Visible = false
return frame
end
local function makeZone( zoneName, image, size, position, parent )
local zone = Instance.new("ImageLabel")
zone.RobloxLocked = true
zone.Name = zoneName
zone.Image = image
zone.Size = size
zone.BackgroundTransparency = 1
zone.Position = position
zone.Parent = parent
return zone
end
local function makeStyledButton( buttonName, size, position, parent, buttonStyle )
local button = Instance.new("ImageButton")
button.RobloxLocked = true
button.Name = buttonName
button.Size = size
button.Position = position
if buttonStyle then
button.Style = buttonStyle
else
button.BackgroundColor3 = Color3.new(0,0,0)
button.BorderColor3 = Color3.new(1,1,1)
end
button.Parent = parent
return button
end
local function makeTextLabel( TextLabelName,text,position,parent )
local label = Instance.new("TextLabel")
label.RobloxLocked = true
label.BackgroundTransparency = 1
label.Size = UDim2.new(0,32,0,14)
label.Name = TextLabelName
label.Font = Enum.Font.Arial
label.TextColor3 = Color3.new(1,1,1)
label.FontSize = Enum.FontSize.Size14
label.Text = text
label.Position = position
label.Parent = parent
end
local Wardrobe = Instance.new("Frame")
Wardrobe.Name = "Wardrobe"
Wardrobe.RobloxLocked = true
Wardrobe.BackgroundTransparency = 1
Wardrobe.Visible = false
Wardrobe.Size = UDim2.new(1,0,1,0)
Wardrobe.Parent = Backpack
local AssetList = Instance.new("Frame")
AssetList.RobloxLocked = true
AssetList.Name = "AssetList"
AssetList.Position = UDim2.new(0,4,0,5)
AssetList.Size = UDim2.new(0,85,1,-5)
AssetList.BackgroundTransparency = 1
AssetList.Visible = true
AssetList.Parent = Wardrobe
local PreviewAssetFrame = Instance.new("Frame")
PreviewAssetFrame.RobloxLocked = true
PreviewAssetFrame.Name = "PreviewAssetFrame"
PreviewAssetFrame.BackgroundTransparency = 1
PreviewAssetFrame.Position = UDim2.new(1,-240,0,30)
PreviewAssetFrame.Size = UDim2.new(0,250,0,250)
PreviewAssetFrame.Parent = Wardrobe
local PreviewAssetBacking = Instance.new("TextButton")
PreviewAssetBacking.RobloxLocked = true
PreviewAssetBacking.Name = "PreviewAssetBacking"
PreviewAssetBacking.Active = false
PreviewAssetBacking.Text = ""
PreviewAssetBacking.AutoButtonColor = false
PreviewAssetBacking.Size = UDim2.new(1,0,1,0)
PreviewAssetBacking.Style = Enum.ButtonStyle.RobloxButton
PreviewAssetBacking.Visible = false
PreviewAssetBacking.ZIndex = 9
PreviewAssetBacking.Parent = PreviewAssetFrame
local PreviewAssetImage = Instance.new("ImageLabel")
PreviewAssetImage.RobloxLocked = true
PreviewAssetImage.Name = "PreviewAssetImage"
PreviewAssetImage.BackgroundTransparency = 0.8
PreviewAssetImage.Position = UDim2.new(0.5,-100,0,0)
PreviewAssetImage.Size = UDim2.new(0,200,0,200)
PreviewAssetImage.BorderSizePixel = 0
PreviewAssetImage.ZIndex = 10
PreviewAssetImage.Parent = PreviewAssetBacking
local AssetNameLabel = Instance.new("TextLabel")
AssetNameLabel.Name = "AssetNameLabel"
AssetNameLabel.RobloxLocked = true
AssetNameLabel.BackgroundTransparency = 1
AssetNameLabel.Position = UDim2.new(0,0,1,-20)
AssetNameLabel.Size = UDim2.new(0.5,0,0,24)
AssetNameLabel.ZIndex = 10
AssetNameLabel.Font = Enum.Font.Arial
AssetNameLabel.Text = ""
AssetNameLabel.TextColor3 = Color3.new(1,1,1)
AssetNameLabel.TextScaled = true
AssetNameLabel.Parent = PreviewAssetBacking
local AssetTypeLabel = AssetNameLabel:clone()
AssetTypeLabel.RobloxLocked = true
AssetTypeLabel.Name = "AssetTypeLabel"
AssetTypeLabel.TextScaled = false
AssetTypeLabel.FontSize = Enum.FontSize.Size18
AssetTypeLabel.Position = UDim2.new(0.5,3,1,-20)
AssetTypeLabel.Parent = PreviewAssetBacking
local PreviewButton = Instance.new("TextButton")
PreviewButton.RobloxLocked = true
PreviewButton.Name = "PreviewButton"
PreviewButton.Text = "Rotate"
PreviewButton.BackgroundColor3 = Color3.new(0,0,0)
PreviewButton.BackgroundTransparency = 0.5
PreviewButton.BorderColor3 = Color3.new(1,1,1)
PreviewButton.Position = UDim2.new(1.2,-62,1,-50)
PreviewButton.Size = UDim2.new(0,125,0,50)
PreviewButton.Font = Enum.Font.ArialBold
PreviewButton.FontSize = Enum.FontSize.Size24
PreviewButton.TextColor3 = Color3.new(1,1,1)
PreviewButton.TextWrapped = true
PreviewButton.TextStrokeTransparency = 0
PreviewButton.Parent = Wardrobe
local CharacterPane = Instance.new("Frame")
CharacterPane.RobloxLocked = true
CharacterPane.Name = "CharacterPane"
CharacterPane.Position = UDim2.new(1,-220,0,32)
CharacterPane.Size = UDim2.new(0,220,1,-40)
CharacterPane.BackgroundTransparency = 1
CharacterPane.Visible = true
CharacterPane.Parent = Wardrobe
--CharacterPane Children
local FaceFrame = makeCharFrame("FacesFrame", CharacterPane)
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf/asset/?id=28")
makeZone("FaceZone","http://www.watrbx.wtf/asset/?id=28",UDim2.new(0,157,0,137),UDim2.new(0.5,-78,0.5,-68),FaceFrame)
makeStyledButton("Face",UDim2.new(0,64,0,64),UDim2.new(0.5,-32,0.5,-135),FaceFrame)
local HeadFrame = makeCharFrame("HeadsFrame", CharacterPane)
makeZone("FaceZone","http://www.watrbx.wtf/asset/?id=28",UDim2.new(0,157,0,137),UDim2.new(0.5,-78,0.5,-68),HeadFrame)
makeStyledButton("Head",UDim2.new(0,64,0,64),UDim2.new(0.5,-32,0.5,-135),HeadFrame)
local HatsFrame = makeCharFrame("HatsFrame", CharacterPane)
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf/asset/?id=29")
local HatsZone = makeZone("HatsZone","http://www.watrbx.wtf/asset/?id=29",UDim2.new(0,186,0,184),UDim2.new(0.5,-93,0.5,-100), HatsFrame)
makeStyledButton("Hat1Button",UDim2.new(0,64,0,64),UDim2.new(0,-1,0,-1),HatsZone,Enum.ButtonStyle.RobloxButton)
makeStyledButton("Hat2Button",UDim2.new(0,64,0,64),UDim2.new(0,63,0,-1),HatsZone,Enum.ButtonStyle.RobloxButton)
makeStyledButton("Hat3Button",UDim2.new(0,64,0,64),UDim2.new(0,127,0,-1),HatsZone,Enum.ButtonStyle.RobloxButton)
local PantsFrame = makeCharFrame("PantsFrame", CharacterPane)
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf/asset/?id=30")
makeZone("PantsZone","http://www.watrbx.wtf/asset/?id=30",UDim2.new(0,121,0,99),UDim2.new(0.5,-60,0.5,-100),PantsFrame)
local pantFrame = Instance.new("Frame")
pantFrame.RobloxLocked = true
pantFrame.Size = UDim2.new(0,25,0,56)
pantFrame.Position = UDim2.new(0.5,-26,0.5,0)
pantFrame.BackgroundColor3 = Color3.new(0,0,0)
pantFrame.BorderColor3 = Color3.new(1,1,1)
pantFrame.Name = "PantFrame"
pantFrame.Parent = PantsFrame
local otherPantFrame = pantFrame:clone()
otherPantFrame.Position = UDim2.new(0.5,3,0.5,0)
otherPantFrame.RobloxLocked = true
otherPantFrame.Parent = PantsFrame
local CurrentPants = Instance.new("ImageButton")
CurrentPants.RobloxLocked = true
CurrentPants.BackgroundTransparency = 1
CurrentPants.ZIndex = 2
CurrentPants.Name = "CurrentPants"
CurrentPants.Position = UDim2.new(0.5,-31,0.5,-4)
CurrentPants.Size = UDim2.new(0,54,0,59)
CurrentPants.Parent = PantsFrame
local MeshFrame = makeCharFrame("PackagesFrame", CharacterPane)
local torsoButton = makeStyledButton("TorsoMeshButton", UDim2.new(0,64,0,64),UDim2.new(0.5,-32,0.5,-110),MeshFrame,Enum.ButtonStyle.RobloxButton)
makeTextLabel("TorsoLabel","Torso",UDim2.new(0.5,-16,0,-25),torsoButton)
local leftLegButton = makeStyledButton("LeftLegMeshButton", UDim2.new(0,64,0,64),UDim2.new(0.5,0,0.5,-25),MeshFrame,Enum.ButtonStyle.RobloxButton)
makeTextLabel("LeftLegLabel","Left Leg",UDim2.new(0.5,-16,0,-25),leftLegButton)
local rightLegButton = makeStyledButton("RightLegMeshButton", UDim2.new(0,64,0,64),UDim2.new(0.5,-64,0.5,-25),MeshFrame,Enum.ButtonStyle.RobloxButton)
makeTextLabel("RightLegLabel","Right Leg",UDim2.new(0.5,-16,0,-25),rightLegButton)
local rightArmButton = makeStyledButton("RightArmMeshButton", UDim2.new(0,64,0,64),UDim2.new(0.5,-96,0.5,-110),MeshFrame,Enum.ButtonStyle.RobloxButton)
makeTextLabel("RightArmLabel","Right Arm",UDim2.new(0.5,-16,0,-25),rightArmButton)
local leftArmButton = makeStyledButton("LeftArmMeshButton", UDim2.new(0,64,0,64),UDim2.new(0.5,32,0.5,-110),MeshFrame,Enum.ButtonStyle.RobloxButton)
makeTextLabel("LeftArmLabel","Left Arm",UDim2.new(0.5,-16,0,-25),leftArmButton)
local TShirtFrame = makeCharFrame("T-ShirtsFrame",CharacterPane)
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf/asset/?id=31")
makeZone("TShirtZone","http://www.watrbx.wtf/asset/?id=31",UDim2.new(0,121,0,154),UDim2.new(0.5,-60,0.5,-100),TShirtFrame)
makeStyledButton("TShirtButton", UDim2.new(0,64,0,64),UDim2.new(0.5,-32,0.5,-64),TShirtFrame)
local ShirtFrame = makeCharFrame("ShirtsFrame", CharacterPane)
makeZone("ShirtZone","http://www.watrbx.wtf/asset/?id=31",UDim2.new(0,121,0,154),UDim2.new(0.5,-60,0.5,-100),ShirtFrame)
makeStyledButton("ShirtButton", UDim2.new(0,64,0,64),UDim2.new(0.5,-32,0.5,-64),ShirtFrame)
local ColorFrame = makeCharFrame("ColorFrame", CharacterPane)
game:GetService("ContentProvider"):Preload("http://www.watrbx.wtf.com/asset/?id=32")
local ColorZone = makeZone("ColorZone","http://www.watrbx.wtf/asset/?id=32", UDim2.new(0,120,0,150),UDim2.new(0.5,-60,0.5,-100),ColorFrame)
makeStyledButton("Head",UDim2.new(0.26,0,0.19,0),UDim2.new(0.37,0,0.02,0),ColorZone).AutoButtonColor = false
makeStyledButton("LeftArm",UDim2.new(0.19,0,0.36,0),UDim2.new(0.78,0,0.26,0),ColorZone).AutoButtonColor = false
makeStyledButton("RightArm",UDim2.new(0.19,0,0.36,0),UDim2.new(0.025,0,0.26,0),ColorZone).AutoButtonColor = false
makeStyledButton("Torso",UDim2.new(0.43,0,0.36,0),UDim2.new(0.28,0,0.26,0),ColorZone).AutoButtonColor = false
makeStyledButton("RightLeg",UDim2.new(0.19,0,0.31,0),UDim2.new(0.275,0,0.67,0),ColorZone).AutoButtonColor = false
makeStyledButton("LeftLeg",UDim2.new(0.19,0,0.31,0),UDim2.new(0.525,0,0.67,0),ColorZone).AutoButtonColor = false
-- Character Panel label (shows what category we are currently browsing)
local CategoryLabel = Instance.new("TextLabel")
CategoryLabel.RobloxLocked = true
CategoryLabel.Name = "CategoryLabel"
CategoryLabel.BackgroundTransparency = 1
CategoryLabel.Font = Enum.Font.ArialBold
CategoryLabel.FontSize = Enum.FontSize.Size18
CategoryLabel.Position = UDim2.new(0,0,0,-7)
CategoryLabel.Size = UDim2.new(1,0,0,20)
CategoryLabel.TextXAlignment = Enum.TextXAlignment.Center
CategoryLabel.Text = "All"
CategoryLabel.TextColor3 = Color3.new(1,1,1)
CategoryLabel.Parent = CharacterPane
--Save Button
local SaveButton = Instance.new("TextButton")
SaveButton.RobloxLocked = true
SaveButton.Name = "SaveButton"
SaveButton.Size = UDim2.new(0.6,0,0,50)
SaveButton.Position = UDim2.new(0.2,0,1,-50)
SaveButton.Style = Enum.ButtonStyle.RobloxButton
SaveButton.Selected = false
SaveButton.Font = Enum.Font.ArialBold
SaveButton.FontSize = Enum.FontSize.Size18
SaveButton.Text = "Save"
SaveButton.TextColor3 = Color3.new(1,1,1)
SaveButton.Parent = CharacterPane
-- no need for this to stick around
script:Destroy()
@@ -0,0 +1,862 @@
-- A couple of necessary functions
local function waitForChild(instance, name)
assert(instance)
assert(name)
while not instance:FindFirstChild(name) do
print('(BPGear): Waiting for ...', instance, name)
instance.ChildAdded:wait()
end
return instance:FindFirstChild(name)
end
local function waitForProperty(instance, property)
assert(instance)
assert(property)
while not instance[property] do
instance.Changed:wait()
end
end
local function IsTouchDevice()
local touchEnabled = false
pcall(function() touchEnabled = Game:GetService('UserInputService').TouchEnabled end)
return touchEnabled
end
waitForChild(game,"Players")
waitForProperty(game.Players,"LocalPlayer")
local player = game.Players.LocalPlayer
local RbxGui, msg = LoadLibrary("RbxGuiThirteen")
if not RbxGui then print("could not find RbxGui!") return end
--- Begin Locals
local StaticTabName = "gear"
local backpack = script.Parent
local screen = script.Parent.Parent
local backpackItems = {}
local buttons = {}
local debounce = false
local browsingMenu = false
local mouseEnterCons = {}
local mouseClickCons = {}
local characterChildAddedCon = nil
local characterChildRemovedCon = nil
local backpackAddCon = nil
local playerBackpack = waitForChild(player,"Backpack")
waitForChild(backpack,"Tabs")
waitForChild(backpack,"Gear")
local gearPreview = waitForChild(backpack.Gear,"GearPreview")
local scroller = waitForChild(backpack.Gear,"GearGridScrollingArea")
local currentLoadout = waitForChild(backpack.Parent,"CurrentLoadout")
local grid = waitForChild(backpack.Gear,"GearGrid")
local gearButton = waitForChild(grid,"GearButton")
local swapSlot = waitForChild(script.Parent,"SwapSlot")
local backpackManager = waitForChild(script.Parent,"CoreScripts/2013/BackpackScripts/BackpackManager")
local backpackOpenEvent = waitForChild(backpackManager,"BackpackOpenEvent")
local backpackCloseEvent = waitForChild(backpackManager,"BackpackCloseEvent")
local tabClickedEvent = waitForChild(backpackManager,"TabClickedEvent")
local resizeEvent = waitForChild(backpackManager,"ResizeEvent")
local searchRequestedEvent = waitForChild(backpackManager,"SearchRequestedEvent")
local tellBackpackReadyFunc = waitForChild(backpackManager,"BackpackReady")
-- creating scroll bar early as to make sure items get placed correctly
local scrollFrame, scrollUp, scrollDown, recalculateScroll = RbxGui.CreateScrollingFrame(nil, "grid", Vector2.new(6, 6))
scrollFrame.Position = UDim2.new(0,0,0,30)
scrollFrame.Size = UDim2.new(1,0,1,-30)
scrollFrame.Parent = backpack.Gear.GearGrid
local scrollBar = Instance.new("Frame")
scrollBar.Name = "ScrollBar"
scrollBar.BackgroundTransparency = 0.9
scrollBar.BackgroundColor3 = Color3.new(1,1,1)
scrollBar.BorderSizePixel = 0
scrollBar.Size = UDim2.new(0, 17, 1, -36)
scrollBar.Position = UDim2.new(0,0,0,18)
scrollBar.Parent = scroller
scrollDown.Position = UDim2.new(0,0,1,-17)
scrollUp.Parent = scroller
scrollDown.Parent = scroller
local scrollFrameLoadout, scrollUpLoadout, scrollDownLoadout, recalculateScrollLoadout = RbxGui.CreateScrollingFrame()
scrollFrameLoadout.Position = UDim2.new(0,0,0,0)
scrollFrameLoadout.Size = UDim2.new(1,0,1,0)
scrollFrameLoadout.Parent = backpack.Gear.GearLoadouts.LoadoutsList
local LoadoutButton = Instance.new("TextButton")
LoadoutButton.RobloxLocked = true
LoadoutButton.Name = "LoadoutButton"
LoadoutButton.Font = Enum.Font.ArialBold
LoadoutButton.FontSize = Enum.FontSize.Size14
LoadoutButton.Position = UDim2.new(0,0,0,0)
LoadoutButton.Size = UDim2.new(1,0,0,32)
LoadoutButton.Style = Enum.ButtonStyle.RobloxButton
LoadoutButton.Text = "Loadout #1"
LoadoutButton.TextColor3 = Color3.new(1,1,1)
LoadoutButton.Parent = scrollFrameLoadout
local LoadoutButtonTwo = LoadoutButton:clone()
LoadoutButtonTwo.Text = "Loadout #2"
LoadoutButtonTwo.Parent = scrollFrameLoadout
local LoadoutButtonThree = LoadoutButton:clone()
LoadoutButtonThree.Text = "Loadout #3"
LoadoutButtonThree.Parent = scrollFrameLoadout
local LoadoutButtonFour = LoadoutButton:clone()
LoadoutButtonFour.Text = "Loadout #4"
LoadoutButtonFour.Parent = scrollFrameLoadout
local scrollBarLoadout = Instance.new("Frame")
scrollBarLoadout.Name = "ScrollBarLoadout"
scrollBarLoadout.BackgroundTransparency = 0.9
scrollBarLoadout.BackgroundColor3 = Color3.new(1,1,1)
scrollBarLoadout.BorderSizePixel = 0
scrollBarLoadout.Size = UDim2.new(0, 17, 1, -36)
scrollBarLoadout.Position = UDim2.new(0,0,0,18)
scrollBarLoadout.Parent = backpack.Gear.GearLoadouts.GearLoadoutsScrollingArea
scrollDownLoadout.Position = UDim2.new(0,0,1,-17)
scrollUpLoadout.Parent = backpack.Gear.GearLoadouts.GearLoadoutsScrollingArea
scrollDownLoadout.Parent = backpack.Gear.GearLoadouts.GearLoadoutsScrollingArea
-- Begin Functions
function removeFromMap(map,object)
for i = 1, #map do
if map[i] == object then
table.remove(map,i)
break
end
end
end
function robloxLock(instance)
instance.RobloxLocked = true
children = instance:GetChildren()
if children then
for i, child in ipairs(children) do
robloxLock(child)
end
end
end
function resize()
local size = 0
if gearPreview.AbsoluteSize.Y > gearPreview.AbsoluteSize.X then
size = gearPreview.AbsoluteSize.X * 0.75
else
size = gearPreview.AbsoluteSize.Y * 0.75
end
waitForChild(gearPreview,"GearImage")
gearPreview.GearImage.Size = UDim2.new(0,size,0,size)
gearPreview.GearImage.Position = UDim2.new(0,gearPreview.AbsoluteSize.X/2 - size/2,0.75,-size)
resizeGrid()
end
function addToGrid(child)
if not child:IsA("Tool") then
if not child:IsA("HopperBin") then
return
end
end
if child:FindFirstChild("RobloxBuildTool") then return end
for i,v in pairs(backpackItems) do -- check to see if we already have this gear registered
if v == child then return end
end
table.insert(backpackItems,child)
local changeCon = child.Changed:connect(function(prop)
if prop == "Name" then
if buttons[child] then
if buttons[child].Image == "" then
buttons[child].GearText.Text = child.Name
end
end
end
end)
local ancestryCon = nil
ancestryCon = child.AncestryChanged:connect(function(theChild,theParent)
local thisObject = nil
for k,v in pairs(backpackItems) do
if v == child then
thisObject = v
break
end
end
waitForProperty(player,"Character")
waitForChild(player,"Backpack")
if (child.Parent ~= player.Backpack and child.Parent ~= player.Character) then
if ancestryCon then ancestryCon:disconnect() end
if changeCon then changeCon:disconnect() end
for k,v in pairs(backpackItems) do
if v == thisObject then
if mouseEnterCons[buttons[v]] then mouseEnterCons[buttons[v]]:disconnect() end
if mouseClickCons[buttons[v]] then mouseClickCons[buttons[v]]:disconnect() end
buttons[v].Parent = nil
buttons[v] = nil
break
end
end
removeFromMap(backpackItems,thisObject)
resizeGrid()
else
resizeGrid()
end
updateGridActive()
end)
resizeGrid()
end
function buttonClick(button)
if button:FindFirstChild("UnequipContextMenu") and not button.Active then
button.UnequipContextMenu.Visible = true
browsingMenu = true
end
end
function previewGear(button)
if not browsingMenu then
gearPreview.Visible = false
gearPreview.GearImage.Image = button.Image
gearPreview.GearStats.GearName.Text = button.GearReference.Value.Name
end
end
function findEmptySlot()
local smallestNum = nil
local loadout = currentLoadout:GetChildren()
for i = 1, #loadout do
if loadout[i]:IsA("Frame") and #loadout[i]:GetChildren() <= 0 then
local frameNum = tonumber(string.sub(loadout[i].Name,5))
if frameNum == 0 then frameNum = 10 end
if not smallestNum or (smallestNum > frameNum) then
smallestNum = frameNum
end
end
end
if smallestNum == 10 then smallestNum = 0 end
return smallestNum
end
function checkForSwap(button,x,y)
local loadoutChildren = currentLoadout:GetChildren()
for i = 1, #loadoutChildren do
if loadoutChildren[i]:IsA("Frame") and string.find(loadoutChildren[i].Name,"Slot") then
if x >= loadoutChildren[i].AbsolutePosition.x and x <= (loadoutChildren[i].AbsolutePosition.x + loadoutChildren[i].AbsoluteSize.x) then
if y >= loadoutChildren[i].AbsolutePosition.y and y <= (loadoutChildren[i].AbsolutePosition.y + loadoutChildren[i].AbsoluteSize.y) then
local slot = tonumber(string.sub(loadoutChildren[i].Name,5))
swapGearSlot(slot,button)
return true
end
end
end
end
return false
end
function resizeGrid()
for k,v in pairs(backpackItems) do
if not v:FindFirstChild("RobloxBuildTool") then
if not buttons[v] then
local buttonClone = gearButton:clone()
buttonClone.Parent = grid.ScrollingFrame
buttonClone.Visible = true
buttonClone.Image = v.TextureId
if buttonClone.Image == "" then
buttonClone.GearText.Text = v.Name
end
buttonClone.GearReference.Value = v
buttonClone.Draggable = true
buttons[v] = buttonClone
if not IsTouchDevice() then
local unequipMenu = getGearContextMenu()
unequipMenu.Visible = false
unequipMenu.Parent = buttonClone
end
local beginPos = nil
buttonClone.DragBegin:connect(function(value)
waitForChild(buttonClone, 'Background')
buttonClone['Background'].ZIndex = 10
buttonClone.ZIndex = 10
beginPos = value
end)
buttonClone.DragStopped:connect(function(x,y)
waitForChild(buttonClone, 'Background')
buttonClone['Background'].ZIndex = 1.0
buttonClone.ZIndex = 2
if beginPos ~= buttonClone.Position then
if not checkForSwap(buttonClone,x,y) then
buttonClone:TweenPosition(beginPos,Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5, true)
buttonClone.Draggable = false
delay(0.5,function()
buttonClone.Draggable = true
end)
else
buttonClone.Position = beginPos
end
end
end)
local clickTime = tick()
mouseEnterCons[buttonClone] = buttonClone.MouseEnter:connect(function() previewGear(buttonClone) end)
mouseClickCons[buttonClone] = buttonClone.MouseButton1Click:connect(function()
local newClickTime = tick()
if buttonClone.Active and (newClickTime - clickTime) < 0.5 then
local slot = findEmptySlot()
if slot then
buttonClone.ZIndex = 1
swapGearSlot(slot,buttonClone)
end
else
buttonClick(buttonClone)
end
clickTime = newClickTime
end)
end
end
end
recalculateScroll()
end
function showPartialGrid(subset)
for k,v in pairs(buttons) do
v.Parent = nil
end
if subset then
for k,v in pairs(subset) do
v.Parent = grid.ScrollingFrame
end
end
recalculateScroll()
end
function showEntireGrid()
for k,v in pairs(buttons) do
v.Parent = grid.ScrollingFrame
end
recalculateScroll()
end
function inLoadout(gear)
local children = currentLoadout:GetChildren()
for i = 1, #children do
if children[i]:IsA("Frame") then
local button = children[i]:GetChildren()
if #button > 0 then
if button[1].GearReference.Value and button[1].GearReference.Value == gear then
return true
end
end
end
end
return false
end
function updateGridActive()
for k,v in pairs(backpackItems) do
if buttons[v] then
local gear = nil
local gearRef = buttons[v]:FindFirstChild("GearReference")
if gearRef then gear = gearRef.Value end
if not gear then
buttons[v].Active = false
elseif inLoadout(gear) then
buttons[v].Active = false
else
buttons[v].Active = true
end
end
end
end
function centerGear(loadoutChildren)
local gearButtons = {}
local lastSlotAdd = nil
for i = 1, #loadoutChildren do
if loadoutChildren[i]:IsA("Frame") and #loadoutChildren[i]:GetChildren() > 0 then
if loadoutChildren[i].Name == "Slot0" then
lastSlotAdd = loadoutChildren[i]
else
table.insert(gearButtons, loadoutChildren[i])
end
end
end
if lastSlotAdd then table.insert(gearButtons,lastSlotAdd) end
local startPos = ( 1 - (#gearButtons * 0.1) ) / 2
for i = 1, #gearButtons do
gearButtons[i]:TweenPosition(UDim2.new(startPos + ((i - 1) * 0.1),0,0,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.25, true)
end
end
function tabClickHandler(tabName)
if tabName == StaticTabName then
backpackOpenHandler(tabName)
else
backpackCloseHandler(tabName)
end
end
function backpackOpenHandler(currentTab)
if currentTab and currentTab ~= StaticTabName then
backpack.Gear.Visible = false
return
end
backpack.Gear.Visible = true
updateGridActive()
resizeGrid()
resize()
tellBackpackReadyFunc:Invoke()
end
function backpackCloseHandler(currentTab)
if currentTab and currentTab ~= StaticTabName then
backpack.Gear.Visible = false
return
end
backpack.Gear.Visible = false
resizeGrid()
resize()
tellBackpackReadyFunc:Invoke()
end
function loadoutCheck(child, selectState)
if not child:IsA("ImageButton") then return end
for k,v in pairs(backpackItems) do
if buttons[v] then
if child:FindFirstChild("GearReference") and buttons[v]:FindFirstChild("GearReference") then
if buttons[v].GearReference.Value == child.GearReference.Value then
buttons[v].Active = selectState
break
end
end
end
end
end
function clearPreview()
gearPreview.GearImage.Image = ""
gearPreview.GearStats.GearName.Text = ""
end
function removeAllEquippedGear(physGear)
local stuff = player.Character:GetChildren()
for i = 1, #stuff do
if ( stuff[i]:IsA("Tool") or stuff[i]:IsA("HopperBin") ) and stuff[i] ~= physGear then
stuff[i].Parent = playerBackpack
end
end
end
function equipGear(physGear)
removeAllEquippedGear(physGear)
physGear.Parent = player.Character
updateGridActive()
end
function unequipGear(physGear)
physGear.Parent = playerBackpack
updateGridActive()
end
function highlight(button)
button.TextColor3 = Color3.new(0,0,0)
button.BackgroundColor3 = Color3.new(0.8,0.8,0.8)
end
function clearHighlight(button)
button.TextColor3 = Color3.new(1,1,1)
button.BackgroundColor3 = Color3.new(0,0,0)
end
function swapGearSlot(slot,gearButton)
if not swapSlot.Value then -- signal loadout to swap a gear out
swapSlot.Slot.Value = slot
swapSlot.GearButton.Value = gearButton
swapSlot.Value = true
updateGridActive()
end
end
local UnequipGearMenuClick = function(element, menu)
if type(element.Action) ~= "number" then return end
local num = element.Action
if num == 1 then -- remove from loadout
unequipGear(menu.Parent.GearReference.Value)
local inventoryButton = menu.Parent
local gearToUnequip = inventoryButton.GearReference.Value
local loadoutChildren = currentLoadout:GetChildren()
local slot = -1
for i = 1, #loadoutChildren do
if loadoutChildren[i]:IsA("Frame") then
local button = loadoutChildren[i]:GetChildren()
if button[1] and button[1].GearReference.Value == gearToUnequip then
slot = button[1].SlotNumber.Text
break
end
end
end
swapGearSlot(slot,nil)
end
end
function setupCharacterConnections()
if backpackAddCon then backpackAddCon:disconnect() end
backpackAddCon = game.Players.LocalPlayer.Backpack.ChildAdded:connect(function(child) addToGrid(child) end)
-- make sure we get all the children
local backpackChildren = game.Players.LocalPlayer.Backpack:GetChildren()
for i = 1, #backpackChildren do
addToGrid(backpackChildren[i])
end
if characterChildAddedCon then characterChildAddedCon:disconnect() end
characterChildAddedCon =
game.Players.LocalPlayer.Character.ChildAdded:connect(function(child)
addToGrid(child)
updateGridActive()
end)
if characterChildRemovedCon then characterChildRemovedCon:disconnect() end
characterChildRemovedCon =
game.Players.LocalPlayer.Character.ChildRemoved:connect(function(child)
updateGridActive()
end)
wait()
centerGear(currentLoadout:GetChildren())
end
function removeCharacterConnections()
if characterChildAddedCon then characterChildAddedCon:disconnect() end
if characterChildRemovedCon then characterChildRemovedCon:disconnect() end
if backpackAddCon then backpackAddCon:disconnect() end
end
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function filterGear(terms)
local filteredGear = {}
for k,v in pairs(backpackItems) do
if buttons[v] then
local gearString = string.lower(buttons[v].GearReference.Value.Name)
gearString = trim(gearString)
for i = 1, #terms do
if string.match(gearString,terms[i]) then
table.insert(filteredGear,buttons[v])
break
end
end
end
end
return filteredGear
end
function splitByWhitespace(text)
if type(text) ~= "string" then return nil end
local terms = {}
for token in string.gmatch(text, "[^%s]+") do
if string.len(token) > 0 then
table.insert(terms,token)
end
end
return terms
end
function showSearchGear(searchTerms)
if not backpack.Gear.Visible then return end -- currently not active tab
local searchTermTable = splitByWhitespace(searchTerms)
if searchTermTable and (#searchTermTable > 0) then
currSearchTerms = searchTermTable
else
currSearchTerms = nil
end
if searchTermTable == nil then
showEntireGrid()
return
end
local filteredButtons = filterGear(currSearchTerms)
showPartialGrid(filteredButtons)
end
function nukeBackpack()
while #buttons > 0 do
table.remove(buttons)
end
buttons = {}
while #backpackItems > 0 do
table.remove(backpackItems)
end
backpackItems = {}
local scrollingFrameChildren = grid.ScrollingFrame:GetChildren()
for i = 1, #scrollingFrameChildren do
scrollingFrameChildren[i]:remove()
end
end
function getGearContextMenu()
local gearContextMenu = Instance.new("Frame")
gearContextMenu.Active = true
gearContextMenu.Name = "UnequipContextMenu"
gearContextMenu.Size = UDim2.new(0,115,0,70)
gearContextMenu.Position = UDim2.new(0,-16,0,-16)
gearContextMenu.BackgroundTransparency = 1
gearContextMenu.Visible = false
local gearContextMenuButton = Instance.new("TextButton")
gearContextMenuButton.Name = "UnequipContextMenuButton"
gearContextMenuButton.Text = ""
gearContextMenuButton.Style = Enum.ButtonStyle.RobloxButtonDefault
gearContextMenuButton.ZIndex = 8
gearContextMenuButton.Size = UDim2.new(1, 0, 1, -20)
gearContextMenuButton.Visible = true
gearContextMenuButton.Parent = gearContextMenu
local elementHeight = 12
local contextMenuElements = {}
local contextMenuElementsName = {"Remove Hotkey"}
for i = 1, #contextMenuElementsName do
local element = {}
element.Type = "Button"
element.Text = contextMenuElementsName[i]
element.Action = i
element.DoIt = UnequipGearMenuClick
table.insert(contextMenuElements,element)
end
for i, contextElement in ipairs(contextMenuElements) do
local element = contextElement
if element.Type == "Button" then
local button = Instance.new("TextButton")
button.Name = "UnequipContextButton" .. i
button.BackgroundColor3 = Color3.new(0,0,0)
button.BorderSizePixel = 0
button.TextXAlignment = Enum.TextXAlignment.Left
button.Text = " " .. contextElement.Text
button.Font = Enum.Font.Arial
button.FontSize = Enum.FontSize.Size14
button.Size = UDim2.new(1, 8, 0, elementHeight)
button.Position = UDim2.new(0,0,0,elementHeight * i)
button.TextColor3 = Color3.new(1,1,1)
button.ZIndex = 9
button.Parent = gearContextMenuButton
if not IsTouchDevice() then
button.MouseButton1Click:connect(function()
if button.Active and not gearContextMenu.Parent.Active then
local success, result = pcall(function() element.DoIt(element, gearContextMenu) end)
browsingMenu = false
gearContextMenu.Visible = false
clearHighlight(button)
clearPreview()
end
end)
button.MouseEnter:connect(function()
if button.Active and gearContextMenu.Parent.Active then
highlight(button)
end
end)
button.MouseLeave:connect(function()
if button.Active and gearContextMenu.Parent.Active then
clearHighlight(button)
end
end)
end
contextElement.Button = button
contextElement.Element = button
elseif element.Type == "Label" then
local frame = Instance.new("Frame")
frame.Name = "ContextLabel" .. i
frame.BackgroundTransparency = 1
frame.Size = UDim2.new(1, 8, 0, elementHeight)
local label = Instance.new("TextLabel")
label.Name = "Text1"
label.BackgroundTransparency = 1
label.BackgroundColor3 = Color3.new(1,1,1)
label.BorderSizePixel = 0
label.TextXAlignment = Enum.TextXAlignment.Left
label.Font = Enum.Font.ArialBold
label.FontSize = Enum.FontSize.Size14
label.Position = UDim2.new(0.0, 0, 0, 0)
label.Size = UDim2.new(0.5, 0, 1, 0)
label.TextColor3 = Color3.new(1,1,1)
label.ZIndex = 9
label.Parent = frame
element.Label1 = label
if element.GetText2 then
label = Instance.new("TextLabel")
label.Name = "Text2"
label.BackgroundTransparency = 1
label.BackgroundColor3 = Color3.new(1,1,1)
label.BorderSizePixel = 0
label.TextXAlignment = Enum.TextXAlignment.Right
label.Font = Enum.Font.Arial
label.FontSize = Enum.FontSize.Size14
label.Position = UDim2.new(0.5, 0, 0, 0)
label.Size = UDim2.new(0.5, 0, 1, 0)
label.TextColor3 = Color3.new(1,1,1)
label.ZIndex = 9
label.Parent = frame
element.Label2 = label
end
frame.Parent = gearContextMenuButton
element.Label = frame
element.Element = frame
end
end
gearContextMenu.ZIndex = 4
gearContextMenu.MouseLeave:connect(function()
browsingMenu = false
gearContextMenu.Visible = false
clearPreview()
end)
robloxLock(gearContextMenu)
return gearContextMenu
end
local backpackChildren = player.Backpack:GetChildren()
for i = 1, #backpackChildren do
addToGrid(backpackChildren[i])
end
------------------------- Start Lifelong Connections -----------------------
resizeEvent.Event:connect(function(absSize)
if debounce then return end
debounce = true
wait()
resize()
resizeGrid()
debounce = false
end)
currentLoadout.ChildAdded:connect(function(child) loadoutCheck(child, false) end)
currentLoadout.ChildRemoved:connect(function(child) loadoutCheck(child, true) end)
currentLoadout.DescendantAdded:connect(function(descendant)
if not backpack.Visible and ( descendant:IsA("ImageButton") or descendant:IsA("TextButton") ) then
centerGear(currentLoadout:GetChildren())
end
end)
currentLoadout.DescendantRemoving:connect(function(descendant)
if not backpack.Visible and ( descendant:IsA("ImageButton") or descendant:IsA("TextButton") ) then
wait()
centerGear(currentLoadout:GetChildren())
end
end)
grid.MouseEnter:connect(function() clearPreview() end)
grid.MouseLeave:connect(function() clearPreview() end)
player.CharacterRemoving:connect(function()
removeCharacterConnections()
nukeBackpack()
end)
player.CharacterAdded:connect(function() setupCharacterConnections() end)
player.ChildAdded:connect(function(child)
if child:IsA("Backpack") then
playerBackpack = child
if backpackAddCon then backpackAddCon:disconnect() end
backpackAddCon = game.Players.LocalPlayer.Backpack.ChildAdded:connect(function(child) addToGrid(child) end)
end
end)
swapSlot.Changed:connect(function()
if not swapSlot.Value then
updateGridActive()
end
end)
local loadoutChildren = currentLoadout:GetChildren()
for i = 1, #loadoutChildren do
if loadoutChildren[i]:IsA("Frame") and string.find(loadoutChildren[i].Name,"Slot") then
loadoutChildren[i].ChildRemoved:connect(function()
updateGridActive()
end)
loadoutChildren[i].ChildAdded:connect(function()
updateGridActive()
end)
end
end
------------------------- End Lifelong Connections -----------------------
resize()
resizeGrid()
-- make sure any items in the loadout are accounted for in inventory
local loadoutChildren = currentLoadout:GetChildren()
for i = 1, #loadoutChildren do
loadoutCheck(loadoutChildren[i], false)
end
if not backpack.Visible then centerGear(currentLoadout:GetChildren()) end
-- make sure that inventory is listening to gear reparenting
if characterChildAddedCon == nil and game.Players.LocalPlayer["Character"] then
setupCharacterConnections()
end
if not backpackAddCon then
backpackAddCon = game.Players.LocalPlayer.Backpack.ChildAdded:connect(function(child) addToGrid(child) end)
end
backpackOpenEvent.Event:connect(backpackOpenHandler)
backpackCloseEvent.Event:connect(backpackCloseHandler)
tabClickedEvent.Event:connect(tabClickHandler)
searchRequestedEvent.Event:connect(showSearchGear)
recalculateScrollLoadout()
@@ -0,0 +1,415 @@
-- This script manages context switches in the backpack (Gear to Wardrobe, etc.) and player state changes. Also manages global functions across different tabs (currently only search)
-- basic functions
local function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
print('(BPManager): Waiting for ...', instance, name)
instance.ChildAdded:wait()
end
return instance:FindFirstChild(name)
end
local function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
end
end
-- don't do anything if we are in an empty game
waitForChild(game,"Players")
if #game.Players:GetChildren() < 1 then
game.Players.ChildAdded:wait()
end
-- make sure everything is loaded in before we do anything
-- get our local player
waitForProperty(game.Players,"LocalPlayer")
local player = game.Players.LocalPlayer
------------------------ Locals ------------------------------
local backpack = script.Parent
waitForChild(backpack,"Gear")
local screen = script.Parent.Parent
assert(screen:IsA("ScreenGui"))
waitForChild(backpack, "Tabs")
waitForChild(backpack.Tabs, "CloseButton")
local closeButton = backpack.Tabs.CloseButton
waitForChild(backpack.Tabs, "InventoryButton")
local inventoryButton = backpack.Tabs.InventoryButton
if True then
waitForChild(backpack.Tabs, "WardrobeButton")
local wardrobeButton = backpack.Tabs.WardrobeButton
end
waitForChild(backpack.Parent,"ControlFrame")
local backpackButton = waitForChild(backpack.Parent.ControlFrame,"BackpackButton")
local currentTab = "gear"
local searchFrame = waitForChild(backpack,"SearchFrame")
waitForChild(backpack.SearchFrame,"SearchBoxFrame")
local searchBox = waitForChild(backpack.SearchFrame.SearchBoxFrame,"SearchBox")
local searchButton = waitForChild(backpack.SearchFrame,"SearchButton")
local resetButton = waitForChild(backpack.SearchFrame,"ResetButton")
local robloxGui = waitForChild(Game.CoreGui, 'RobloxGui')
local currentLoadout = waitForChild(robloxGui, 'CurrentLoadout')
local loadoutBackground = waitForChild(currentLoadout, 'Background')
local canToggle = true
local readyForNextEvent = true
local backpackIsOpen = false
local active = true
local humanoidDiedCon = nil
local backpackButtonPos
local guiTweenSpeed = 0.25 -- how quickly we open/close the backpack
local searchDefaultText = "Search..."
local tilde = "~"
local backquote = "`"
local backpackSize = UDim2.new(0, 600, 0, 400)
if robloxGui.AbsoluteSize.Y <= 320 then
backpackSize = UDim2.new(0, 200, 0, 140)
end
------------------------ End Locals ---------------------------
---------------------------------------- Public Event Setup ----------------------------------------
function createPublicEvent(eventName)
assert(eventName, "eventName is nil")
assert(tostring(eventName),"eventName is not a string")
local newEvent = Instance.new("BindableEvent")
newEvent.Name = tostring(eventName)
newEvent.Parent = script
return newEvent
end
function createPublicFunction(funcName, invokeFunc)
assert(funcName, "funcName is nil")
assert(tostring(funcName), "funcName is not a string")
assert(invokeFunc, "invokeFunc is nil")
assert(type(invokeFunc) == "function", "invokeFunc should be of type 'function'")
local newFunction = Instance.new("BindableFunction")
newFunction.Name = tostring(funcName)
newFunction.OnInvoke = invokeFunc
newFunction.Parent = script
return newFunction
end
-- Events
local resizeEvent = createPublicEvent("ResizeEvent")
local backpackOpenEvent = createPublicEvent("BackpackOpenEvent")
local backpackCloseEvent = createPublicEvent("BackpackCloseEvent")
local tabClickedEvent = createPublicEvent("TabClickedEvent")
local searchRequestedEvent = createPublicEvent("SearchRequestedEvent")
---------------------------------------- End Public Event Setup ----------------------------------------
--------------------------- Internal Functions ----------------------------------------
function deactivateBackpack()
backpack.Visible = false
active = false
end
function activateBackpack()
initHumanoidDiedConnections()
active = true
backpack.Visible = backpackIsOpen
if backpackIsOpen then
toggleBackpack()
end
end
function initHumanoidDiedConnections()
if humanoidDiedCon then
humanoidDiedCon:disconnect()
end
waitForProperty(game.Players.LocalPlayer,"Character")
waitForChild(game.Players.LocalPlayer.Character,"Humanoid")
humanoidDiedCon = game.Players.LocalPlayer.Character.Humanoid.Died:connect(deactivateBackpack)
end
local hideBackpack = function()
backpackIsOpen = false
readyForNextEvent = false
backpackButton.Selected = false
resetSearch()
backpackCloseEvent:Fire(currentTab)
backpack.Tabs.Visible = false
searchFrame.Visible = false
backpack:TweenSizeAndPosition(UDim2.new(0, backpackSize.X.Offset,0, 0), UDim2.new(0.5, -backpackSize.X.Offset/2, 1, -85), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, guiTweenSpeed, true,
function()
game.GuiService:RemoveCenterDialog(backpack)
backpack.Visible = false
backpackButton.Selected = false
end)
delay(guiTweenSpeed,function()
game.GuiService:RemoveCenterDialog(backpack)
backpack.Visible = false
backpackButton.Selected = false
readyForNextEvent = true
canToggle = true
end)
end
function showBackpack()
game.GuiService:AddCenterDialog(backpack, Enum.CenterDialogType.PlayerInitiatedDialog,
function()
backpack.Visible = true
backpackButton.Selected = true
end,
function()
backpack.Visible = false
backpackButton.Selected = false
end)
backpack.Visible = true
backpackButton.Selected = true
backpack:TweenSizeAndPosition(backpackSize, UDim2.new(0.5, -backpackSize.X.Offset/2, 1, -backpackSize.Y.Offset - 88), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, guiTweenSpeed, true)
delay(guiTweenSpeed,function()
backpack.Tabs.Visible = false
searchFrame.Visible = true
backpackOpenEvent:Fire(currentTab)
canToggle = true
readyForNextEvent = true
backpackButton.Image = 'http://www.watrbx.wtf/asset/?id=21'
backpackButton.Position = UDim2.new(0.5, -60, 1, -backpackSize.Y.Offset - 103)
end)
end
function toggleBackpack()
if not game.Players.LocalPlayer then return end
if not game.Players.LocalPlayer["Character"] then return end
if not canToggle then return end
if not readyForNextEvent then return end
readyForNextEvent = false
canToggle = false
backpackIsOpen = not backpackIsOpen
if backpackIsOpen then
loadoutBackground.Image = 'http://www.watrbx.wtf/asset/?id=22'
loadoutBackground.Position = UDim2.new(-0.03, 0, -0.17, 0)
loadoutBackground.Size = UDim2.new(1.05, 0, 1.25, 0)
loadoutBackground.ZIndex = 2.0
loadoutBackground.Visible = true
--backpackButton.Position = UDim2.new(0.5, -60, 1, -503)
showBackpack()
else
backpackButton.Position = UDim2.new(0.5, -60, 1, -44)
loadoutBackground.Visible = false
backpackButton.Selected = false
backpackButton.Image = "http://www.watrbx.wtf/asset/?id=21"
loadoutBackground.Image = 'http://www.watrbx.wtf.com/asset/?id=23'
loadoutBackground.Position = UDim2.new(-0.1, 0, -0.1, 0)
loadoutBackground.Size = UDim2.new(1.2, 0, 1.2, 0)
hideBackpack()
local clChildren = currentLoadout:GetChildren()
for i = 1, #clChildren do
if clChildren[i] and clChildren[i]:IsA('Frame') then
local frame = clChildren[i]
if #frame:GetChildren() > 0 then
backpackButton.Position = UDim2.new(0.5, -60, 1, -108)
backpackButton.Visible = true
loadoutBackground.Visible = true
if frame:GetChildren()[1]:IsA('ImageButton') then
local imgButton = frame:GetChildren()[1]
imgButton.Active = true
imgButton.Draggable = false
end
end
end
end
end
end
function closeBackpack()
if backpackIsOpen then
toggleBackpack()
end
end
function setSelected(tab)
assert(tab)
assert(tab:IsA("TextButton"))
tab.BackgroundColor3 = Color3.new(1,1,1)
tab.TextColor3 = Color3.new(0,0,0)
tab.Selected = true
tab.ZIndex = 3
end
function setUnselected(tab)
assert(tab)
assert(tab:IsA("TextButton"))
tab.BackgroundColor3 = Color3.new(0,0,0)
tab.TextColor3 = Color3.new(1,1,1)
tab.Selected = false
tab.ZIndex = 1
end
function updateTabGui(selectedTab)
assert(selectedTab)
if selectedTab == "gear" then
setSelected(inventoryButton)
setUnselected(wardrobeButton)
elseif selectedTab == "wardrobe" then
setSelected(wardrobeButton)
setUnselected(inventoryButton)
end
end
function mouseLeaveTab(button)
assert(button)
assert(button:IsA("TextButton"))
if button.Selected then return end
button.BackgroundColor3 = Color3.new(0,0,0)
end
function mouseOverTab(button)
assert(button)
assert(button:IsA("TextButton"))
if button.Selected then return end
button.BackgroundColor3 = Color3.new(39/255,39/255,39/255)
end
function newTabClicked(tabName)
assert(tabName)
tabName = string.lower(tabName)
currentTab = tabName
updateTabGui(tabName)
tabClickedEvent:Fire(tabName)
resetSearch()
end
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function splitByWhitespace(text)
if type(text) ~= "string" then return nil end
local terms = {}
for token in string.gmatch(text, "[^%s]+") do
if string.len(token) > 0 then
table.insert(terms,token)
end
end
return terms
end
function resetSearchBoxGui()
resetButton.Visible = false
searchBox.Text = searchDefaultText
end
function doSearch()
local searchText = searchBox.Text
if searchText == "" then
resetSearch()
return
end
searchText = trim(searchText)
resetButton.Visible = true
termTable = splitByWhitespace(searchText)
searchRequestedEvent:Fire(searchText) -- todo: replace this with termtable when table passing is possible
end
function resetSearch()
resetSearchBoxGui()
searchRequestedEvent:Fire()
end
local backpackReady = function()
readyForNextEvent = true
end
--------------------------- End Internal Functions -------------------------------------
------------------------------ Public Functions Setup -------------------------------------
createPublicFunction("CloseBackpack", hideBackpack)
createPublicFunction("BackpackReady", backpackReady)
------------------------------ End Public Functions Setup ---------------------------------
------------------------ Connections/Script Main -------------------------------------------
inventoryButton.MouseButton1Click:connect(function() newTabClicked("gear") end)
inventoryButton.MouseEnter:connect(function() mouseOverTab(inventoryButton) end)
inventoryButton.MouseLeave:connect(function() mouseLeaveTab(inventoryButton) end)
if True then
wardrobeButton.MouseButton1Click:connect(function() newTabClicked("wardrobe") end)
wardrobeButton.MouseEnter:connect(function() mouseOverTab(wardrobeButton) end)
wardrobeButton.MouseLeave:connect(function() mouseLeaveTab(wardrobeButton) end)
end
closeButton.MouseButton1Click:connect(closeBackpack)
screen.Changed:connect(function(prop)
if prop == "AbsoluteSize" then
resizeEvent:Fire(screen.AbsoluteSize)
end
end)
-- GuiService key setup
game:GetService("GuiService"):AddKey(tilde)
game:GetService("GuiService"):AddKey(backquote)
game:GetService("GuiService").KeyPressed:connect(function(key)
if not active then return end
if key == tilde or key == backquote then
toggleBackpack()
end
end)
backpackButton.MouseButton1Click:connect(function()
if not active then return end
toggleBackpack()
end)
if game.Players.LocalPlayer["Character"] then
activateBackpack()
end
game.Players.LocalPlayer.CharacterAdded:connect(activateBackpack)
-- search functions
searchBox.FocusLost:connect(function(enterPressed)
if enterPressed or searchBox.Text ~= "" then
doSearch()
elseif searchBox.Text == "" then
resetSearch()
end
end)
searchButton.MouseButton1Click:connect(doSearch)
resetButton.MouseButton1Click:connect(resetSearch)
if searchFrame and robloxGui.AbsoluteSize.Y <= 320 then
searchFrame.RobloxLocked = false
searchFrame:Destroy()
end
--backpackButton.Visible = true
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1 @@
print("Loading Game")
@@ -0,0 +1,560 @@
function waitForProperty(instance, name)
while not instance[name] do
instance.Changed:wait()
end
end
function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
instance.ChildAdded:wait()
end
end
local mainFrame
local choices = {}
local lastChoice
local choiceMap = {}
local currentConversationDialog
local currentConversationPartner
local currentAbortDialogScript
local tooFarAwayMessage = "You are too far away to chat!"
local tooFarAwaySize = 300
local characterWanderedOffMessage = "Chat ended because you walked away"
local characterWanderedOffSize = 350
local conversationTimedOut = "Chat ended because you didn't reply"
local conversationTimedOutSize = 350
local player
local screenGui
local chatNotificationGui
local messageDialog
local timeoutScript
local reenableDialogScript
local dialogMap = {}
local dialogConnections = {}
local gui = nil
waitForChild(game,"CoreGui")
waitForChild(game.CoreGui,"RobloxGui")
if game.CoreGui.RobloxGui:FindFirstChild("ControlFrame") then
gui = game.CoreGui.RobloxGui.ControlFrame
else
gui = game.CoreGui.RobloxGui
end
function currentTone()
if currentConversationDialog then
return currentConversationDialog.Tone
else
return Enum.DialogTone.Neutral
end
end
function createChatNotificationGui()
chatNotificationGui = Instance.new("BillboardGui")
chatNotificationGui.Name = "ChatNotificationGui"
chatNotificationGui.ExtentsOffset = Vector3.new(0,1,0)
chatNotificationGui.Size = UDim2.new(4, 0, 5.42857122, 0)
chatNotificationGui.SizeOffset = Vector2.new(0,0)
chatNotificationGui.StudsOffset = Vector3.new(0.4, 4.3, 0)
chatNotificationGui.Enabled = true
chatNotificationGui.RobloxLocked = true
chatNotificationGui.Active = true
local image = Instance.new("ImageLabel")
image.Name = "Image"
image.Active = false
image.BackgroundTransparency = 1
image.Position = UDim2.new(0,0,0,0)
image.Size = UDim2.new(1.0,0,1.0,0)
image.Image = ""
image.RobloxLocked = true
image.Parent = chatNotificationGui
local button = Instance.new("ImageButton")
button.Name = "Button"
button.AutoButtonColor = false
button.Position = UDim2.new(0.0879999995, 0, 0.0529999994, 0)
button.Size = UDim2.new(0.829999983, 0, 0.460000008, 0)
button.Image = ""
button.BackgroundTransparency = 1
button.RobloxLocked = true
button.Parent = image
end
function getChatColor(tone)
if tone == Enum.DialogTone.Neutral then
return Enum.ChatColor.Blue
elseif tone == Enum.DialogTone.Friendly then
return Enum.ChatColor.Green
elseif tone == Enum.DialogTone.Enemy then
return Enum.ChatColor.Red
end
end
function styleChoices(tone)
for i, obj in pairs(choices) do
resetColor(obj, tone)
end
resetColor(lastChoice, tone)
end
function styleMainFrame(tone)
if tone == Enum.DialogTone.Neutral then
mainFrame.Style = Enum.FrameStyle.ChatBlue
mainFrame.Tail.Image = "rbxasset://textures/chatBubble_botBlue_tailRight.png"
elseif tone == Enum.DialogTone.Friendly then
mainFrame.Style = Enum.FrameStyle.ChatGreen
mainFrame.Tail.Image = "rbxasset://textures/chatBubble_botGreen_tailRight.png"
elseif tone == Enum.DialogTone.Enemy then
mainFrame.Style = Enum.FrameStyle.ChatRed
mainFrame.Tail.Image = "rbxasset://textures/chatBubble_botRed_tailRight.png"
end
styleChoices(tone)
end
function setChatNotificationTone(gui, purpose, tone)
if tone == Enum.DialogTone.Neutral then
gui.Image.Image = "rbxasset://textures/chatBubble_botBlue_notify_bkg.png"
elseif tone == Enum.DialogTone.Friendly then
gui.Image.Image = "rbxasset://textures/chatBubble_botGreen_notify_bkg.png"
elseif tone == Enum.DialogTone.Enemy then
gui.Image.Image = "rbxasset://textures/chatBubble_botRed_notify_bkg.png"
end
if purpose == Enum.DialogPurpose.Quest then
gui.Image.Button.Image = "rbxasset://textures/chatBubble_bot_notify_bang.png"
elseif purpose == Enum.DialogPurpose.Help then
gui.Image.Button.Image = "rbxasset://textures/chatBubble_bot_notify_question.png"
elseif purpose == Enum.DialogPurpose.Shop then
gui.Image.Button.Image = "rbxasset://textures/chatBubble_bot_notify_money.png"
end
end
function createMessageDialog()
messageDialog = Instance.new("Frame");
messageDialog.Name = "DialogScriptMessage"
messageDialog.Style = Enum.FrameStyle.RobloxRound
messageDialog.Visible = false
local text = Instance.new("TextLabel")
text.Name = "Text"
text.Position = UDim2.new(0,0,0,-1)
text.Size = UDim2.new(1,0,1,0)
text.FontSize = Enum.FontSize.Size14
text.BackgroundTransparency = 1
text.TextColor3 = Color3.new(1,1,1)
text.RobloxLocked = true
text.Parent = messageDialog
end
function showMessage(msg, size)
messageDialog.Text.Text = msg
messageDialog.Size = UDim2.new(0,size,0,40)
messageDialog.Position = UDim2.new(0.5, -size/2, 0.5, -40)
messageDialog.Visible = true
wait(2)
messageDialog.Visible = false
end
function variableDelay(str)
local length = math.min(string.len(str), 100)
wait(0.75 + ((length/75) * 1.5))
end
function resetColor(frame, tone)
if tone == Enum.DialogTone.Neutral then
frame.BackgroundColor3 = Color3.new(0/255, 0/255, 179/255)
frame.Number.TextColor3 = Color3.new(45/255, 142/255, 245/255)
elseif tone == Enum.DialogTone.Friendly then
frame.BackgroundColor3 = Color3.new(0/255, 77/255, 0/255)
frame.Number.TextColor3 = Color3.new(0/255, 190/255, 0/255)
elseif tone == Enum.DialogTone.Enemy then
frame.BackgroundColor3 = Color3.new(140/255, 0/255, 0/255)
frame.Number.TextColor3 = Color3.new(255/255,88/255, 79/255)
end
end
function highlightColor(frame, tone)
if tone == Enum.DialogTone.Neutral then
frame.BackgroundColor3 = Color3.new(2/255, 108/255, 255/255)
frame.Number.TextColor3 = Color3.new(1, 1, 1)
elseif tone == Enum.DialogTone.Friendly then
frame.BackgroundColor3 = Color3.new(0/255, 128/255, 0/255)
frame.Number.TextColor3 = Color3.new(1, 1, 1)
elseif tone == Enum.DialogTone.Enemy then
frame.BackgroundColor3 = Color3.new(204/255, 0/255, 0/255)
frame.Number.TextColor3 = Color3.new(1, 1, 1)
end
end
function wanderDialog()
print("Wander")
mainFrame.Visible = false
endDialog()
showMessage(characterWanderedOffMessage, characterWanderedOffSize)
end
function timeoutDialog()
print("Timeout")
mainFrame.Visible = false
endDialog()
showMessage(conversationTimedOut, conversationTimedOutSize)
end
function normalEndDialog()
print("Done")
endDialog()
end
function endDialog()
if currentAbortDialogScript then
currentAbortDialogScript:Remove()
currentAbortDialogScript = nil
end
local dialog = currentConversationDialog
currentConversationDialog = nil
if dialog and dialog.InUse then
local reenableScript = reenableDialogScript:Clone()
reenableScript.archivable = false
reenableScript.Disabled = false
reenableScript.Parent = dialog
end
for dialog, gui in pairs(dialogMap) do
if dialog and gui then
gui.Enabled = not dialog.InUse
end
end
currentConversationPartner = nil
end
function sanitizeMessage(msg)
if string.len(msg) == 0 then
return "..."
else
return msg
end
end
function selectChoice(choice)
renewKillswitch(currentConversationDialog)
--First hide the Gui
mainFrame.Visible = false
if choice == lastChoice then
game.Chat:Chat(game.Players.LocalPlayer.Character, "Goodbye!", getChatColor(currentTone()))
normalEndDialog()
else
local dialogChoice = choiceMap[choice]
game.Chat:Chat(game.Players.LocalPlayer.Character, sanitizeMessage(dialogChoice.UserDialog), getChatColor(currentTone()))
wait(1)
currentConversationDialog:SignalDialogChoiceSelected(player, dialogChoice)
game.Chat:Chat(currentConversationPartner, sanitizeMessage(dialogChoice.ResponseDialog), getChatColor(currentTone()))
variableDelay(dialogChoice.ResponseDialog)
presentDialogChoices(currentConversationPartner, dialogChoice:GetChildren())
end
end
function newChoice(numberText)
local frame = Instance.new("TextButton")
frame.BackgroundColor3 = Color3.new(0/255, 0/255, 179/255)
frame.AutoButtonColor = false
frame.BorderSizePixel = 0
frame.Text = ""
frame.MouseEnter:connect(function() highlightColor(frame, currentTone()) end)
frame.MouseLeave:connect(function() resetColor(frame, currentTone()) end)
frame.MouseButton1Click:connect(function() selectChoice(frame) end)
frame.RobloxLocked = true
local number = Instance.new("TextLabel")
number.Name = "Number"
number.TextColor3 = Color3.new(127/255, 212/255, 255/255)
number.Text = numberText
number.FontSize = Enum.FontSize.Size14
number.BackgroundTransparency = 1
number.Position = UDim2.new(0,4,0,2)
number.Size = UDim2.new(0,20,0,24)
number.TextXAlignment = Enum.TextXAlignment.Left
number.TextYAlignment = Enum.TextYAlignment.Top
number.RobloxLocked = true
number.Parent = frame
local prompt = Instance.new("TextLabel")
prompt.Name = "UserPrompt"
prompt.BackgroundTransparency = 1
prompt.TextColor3 = Color3.new(1,1,1)
prompt.FontSize = Enum.FontSize.Size14
prompt.Position = UDim2.new(0,28, 0, 2)
prompt.Size = UDim2.new(1,-32, 1, -4)
prompt.TextXAlignment = Enum.TextXAlignment.Left
prompt.TextYAlignment = Enum.TextYAlignment.Top
prompt.TextWrap = true
prompt.RobloxLocked = true
prompt.Parent = frame
return frame
end
function initialize(parent)
choices[1] = newChoice("1)")
choices[2] = newChoice("2)")
choices[3] = newChoice("3)")
choices[4] = newChoice("4)")
lastChoice = newChoice("5)")
lastChoice.UserPrompt.Text = "Goodbye!"
lastChoice.Size = UDim2.new(1,0,0,28)
mainFrame = Instance.new("Frame")
mainFrame.Name = "UserDialogArea"
mainFrame.Size = UDim2.new(0, 350, 0, 200)
mainFrame.Style = Enum.FrameStyle.ChatBlue
mainFrame.Visible = false
imageLabel = Instance.new("ImageLabel")
imageLabel.Name = "Tail"
imageLabel.Size = UDim2.new(0,62,0,53)
imageLabel.Position = UDim2.new(1,8,0.25)
imageLabel.Image = "rbxasset://textures/chatBubble_botBlue_tailRight.png"
imageLabel.BackgroundTransparency = 1
imageLabel.RobloxLocked = true
imageLabel.Parent = mainFrame
for n, obj in pairs(choices) do
obj.RobloxLocked = true
obj.Parent = mainFrame
end
lastChoice.RobloxLocked = true
lastChoice.Parent = mainFrame
mainFrame.RobloxLocked = true
mainFrame.Parent = parent
end
function presentDialogChoices(talkingPart, dialogChoices)
if not currentConversationDialog then
return
end
currentConversationPartner = talkingPart
sortedDialogChoices = {}
for n, obj in pairs(dialogChoices) do
if obj:IsA("DialogChoice") then
table.insert(sortedDialogChoices, obj)
end
end
table.sort(sortedDialogChoices, function(a,b) return a.Name < b.Name end)
if #sortedDialogChoices == 0 then
normalEndDialog()
return
end
local pos = 1
local yPosition = 0
choiceMap = {}
for n, obj in pairs(choices) do
obj.Visible = false
end
for n, obj in pairs(sortedDialogChoices) do
if pos <= #choices then
--3 lines is the maximum, set it to that temporarily
choices[pos].Size = UDim2.new(1, 0, 0, 24*3)
choices[pos].UserPrompt.Text = obj.UserDialog
local height = math.ceil(choices[pos].UserPrompt.TextBounds.Y/24)*24
choices[pos].Position = UDim2.new(0, 0, 0, yPosition)
choices[pos].Size = UDim2.new(1, 0, 0, height)
choices[pos].Visible = true
choiceMap[choices[pos]] = obj
yPosition = yPosition + height
pos = pos + 1
end
end
lastChoice.Position = UDim2.new(0,0,0,yPosition)
lastChoice.Number.Text = pos .. ")"
mainFrame.Size = UDim2.new(0, 350, 0, yPosition+24+32)
mainFrame.Position = UDim2.new(0,20,0.0, -mainFrame.Size.Y.Offset-20)
styleMainFrame(currentTone())
mainFrame.Visible = true
end
function doDialog(dialog)
while not Instance.Lock(dialog, player) do
wait()
end
if dialog.InUse then
Instance.Unlock(dialog)
return
else
dialog.InUse = true
Instance.Unlock(dialog)
end
currentConversationDialog = dialog
game.Chat:Chat(dialog.Parent, dialog.InitialPrompt, getChatColor(dialog.Tone))
variableDelay(dialog.InitialPrompt)
presentDialogChoices(dialog.Parent, dialog:GetChildren())
end
function renewKillswitch(dialog)
if currentAbortDialogScript then
currentAbortDialogScript:Remove()
currentAbortDialogScript = nil
end
currentAbortDialogScript = timeoutScript:Clone()
currentAbortDialogScript.archivable = false
currentAbortDialogScript.Disabled = false
currentAbortDialogScript.Parent = dialog
end
function checkForLeaveArea()
while currentConversationDialog do
if currentConversationDialog.Parent and (player:DistanceFromCharacter(currentConversationDialog.Parent.Position) >= currentConversationDialog.ConversationDistance) then
wanderDialog()
end
wait(1)
end
end
function startDialog(dialog)
if dialog.Parent and dialog.Parent:IsA("BasePart") then
if player:DistanceFromCharacter(dialog.Parent.Position) >= dialog.ConversationDistance then
showMessage(tooFarAwayMessage, tooFarAwaySize)
return
end
for dialog, gui in pairs(dialogMap) do
if dialog and gui then
gui.Enabled = false
end
end
renewKillswitch(dialog)
delay(1, checkForLeaveArea)
doDialog(dialog)
end
end
function removeDialog(dialog)
if dialogMap[dialog] then
dialogMap[dialog]:Remove()
dialogMap[dialog] = nil
end
if dialogConnections[dialog] then
dialogConnections[dialog]:disconnect()
dialogConnections[dialog] = nil
end
end
function addDialog(dialog)
if dialog.Parent then
if dialog.Parent:IsA("BasePart") then
local chatGui = chatNotificationGui:clone()
chatGui.Enabled = not dialog.InUse
chatGui.Adornee = dialog.Parent
chatGui.RobloxLocked = true
chatGui.Parent = game.CoreGui
chatGui.Image.Button.MouseButton1Click:connect(function() startDialog(dialog) end)
setChatNotificationTone(chatGui, dialog.Purpose, dialog.Tone)
dialogMap[dialog] = chatGui
dialogConnections[dialog] = dialog.Changed:connect(function(prop)
if prop == "Parent" and dialog.Parent then
--This handles the reparenting case, seperate from removal case
removeDialog(dialog)
addDialog(dialog)
elseif prop == "InUse" then
chatGui.Enabled = not currentConversationDialog and not dialog.InUse
if dialog == currentConversationDialog then
timeoutDialog()
end
elseif prop == "Tone" or prop == "Purpose" then
setChatNotificationTone(chatGui, dialog.Purpose, dialog.Tone)
end
end)
else -- still need to listen to parent changes even if current parent is not a BasePart
dialogConnections[dialog] = dialog.Changed:connect(function(prop)
if prop == "Parent" and dialog.Parent then
--This handles the reparenting case, seperate from removal case
removeDialog(dialog)
addDialog(dialog)
end
end)
end
end
end
function fetchScripts()
local model = game:GetService("InsertService"):LoadAsset(39226062)
if type(model) == "string" then -- load failed, lets try again
wait(0.1)
model = game:GetService("InsertService"):LoadAsset(39226062)
end
if type(model) == "string" then -- not going to work, lets bail
return
end
waitForChild(model,"TimeoutScript")
timeoutScript = model.TimeoutScript
waitForChild(model,"ReenableDialogScript")
reenableDialogScript = model.ReenableDialogScript
end
function onLoad()
waitForProperty(game.Players, "LocalPlayer")
player = game.Players.LocalPlayer
waitForProperty(player, "Character")
--print("Fetching Scripts")
fetchScripts()
--print("Creating Guis")
createChatNotificationGui()
--print("Creating MessageDialog")
createMessageDialog()
messageDialog.RobloxLocked = true
messageDialog.Parent = gui
--print("Waiting for BottomLeftControl")
waitForChild(gui, "BottomLeftControl")
--print("Initializing Frame")
local frame = Instance.new("Frame")
frame.Name = "DialogFrame"
frame.Position = UDim2.new(0,0,0,0)
frame.Size = UDim2.new(0,0,0,0)
frame.BackgroundTransparency = 1
frame.RobloxLocked = true
frame.Parent = gui.BottomLeftControl
initialize(frame)
--print("Adding Dialogs")
game.CollectionService.ItemAdded:connect(function(obj) if obj:IsA("Dialog") then addDialog(obj) end end)
game.CollectionService.ItemRemoved:connect(function(obj) if obj:IsA("Dialog") then removeDialog(obj) end end)
for i, obj in pairs(game.CollectionService:GetCollection("Dialog")) do
if obj:IsA("Dialog") then
addDialog(obj)
end
end
end
onLoad()
@@ -0,0 +1,36 @@
-- Library Registration Script
-- This script is used to register RbxLua Modules on game servers, so game scripts have
-- access to all of the Modules (otherwise only local scripts do)
local function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
instance.ChildAdded:wait()
print("Waiting...")
end
return instance:FindFirstChild(name)
end
local function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
print("Waiting...")
end
end
local sc = game:GetService("ScriptContext")
local RobloxGui = game:GetService("CoreGui"):WaitForChild("RobloxGui")
local tries = 0
while not sc and tries < 3 do
tries = tries + 1
sc = game:GetService("ScriptContext")
wait(0.2)
end
if sc then
LoadLibrary("RbxGuiThirteen")
LoadLibrary("RbxGearThirteen")
LoadLibrary("RbxUtility")
LoadLibrary("RbxStamperThirteen")
else
print("failed to find script context, Modules did not load")
end
@@ -0,0 +1,214 @@
function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
end
end
function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
instance.ChildAdded:wait()
end
end
waitForProperty(game.Players,"LocalPlayer")
waitForChild(script.Parent,"Popup")
waitForChild(script.Parent.Popup,"AcceptButton")
script.Parent.Popup.AcceptButton.Modal = true
local localPlayer = game.Players.LocalPlayer
local acceptedTeleport = Instance.new("IntValue")
local friendRequestBlacklist = {}
local teleportEnabled = true
local makePopupInvisible = function()
if script.Parent.Popup then script.Parent.Popup.Visible = false end
end
function makeFriend(fromPlayer,toPlayer)
local popup = script.Parent:FindFirstChild("Popup")
if popup == nil then return end -- there is no popup!
if popup.Visible then return end -- currently popping something, abort!
if friendRequestBlacklist[fromPlayer] then return end -- previously cancelled friend request, we don't want it!
popup.PopupText.Text = "Accept Friend Request from " .. tostring(fromPlayer.Name) .. "?"
popup.PopupImage.Image = "http://www.watrbx.wtf/thumbs/avatar.ashx?userId="..tostring(fromPlayer.userId).."&x=352&y=352"
showTwoButtons()
popup.Visible = true
popup.AcceptButton.Text = "Accept"
popup.DeclineButton.Text = "Decline"
popup:TweenSize(UDim2.new(0,330,0,350),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true)
local yesCon, noCon
yesCon = popup.AcceptButton.MouseButton1Click:connect(function()
popup.Visible = false
toPlayer:RequestFriendship(fromPlayer)
if yesCon then yesCon:disconnect() end
if noCon then noCon:disconnect() end
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
noCon = popup.DeclineButton.MouseButton1Click:connect(function()
popup.Visible = false
toPlayer:RevokeFriendship(fromPlayer)
friendRequestBlacklist[fromPlayer] = true
print("pop up blacklist")
if yesCon then yesCon:disconnect() end
if noCon then noCon:disconnect() end
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
end
game.Players.FriendRequestEvent:connect(function(fromPlayer,toPlayer,event)
-- if this doesn't involve me, then do nothing
if fromPlayer ~= localPlayer and toPlayer ~= localPlayer then return end
if fromPlayer == localPlayer then
if event == Enum.FriendRequestEvent.Accept then
game:GetService("GuiService"):SendNotification("You are Friends",
"With " .. toPlayer.Name .. "!",
"http://www.watrbx.wtf/thumbs/avatar.ashx?userId="..tostring(toPlayer.userId).."&x=512&y=512",
5,
function()
end)
end
elseif toPlayer == localPlayer then
if event == Enum.FriendRequestEvent.Issue then
if friendRequestBlacklist[fromPlayer] then return end -- previously cancelled friend request, we don't want it!
game:GetService("GuiService"):SendNotification("Friend Request",
"From " .. fromPlayer.Name,
"http://www.watrbx.wtf/thumbs/avatar.ashx?userId="..tostring(fromPlayer.userId).."&x=512&y=512",
8,
function()
makeFriend(fromPlayer,toPlayer)
end)
elseif event == Enum.FriendRequestEvent.Accept then
game:GetService("GuiService"):SendNotification("You are Friends",
"With " .. fromPlayer.Name .. "!",
"http://www.watrbx.wtf/thumbs/avatar.ashx?userId="..tostring(fromPlayer.userId).."&x=512&y=512",
5,
function()
end)
end
end
end)
function showOneButton()
local popup = script.Parent:FindFirstChild("Popup")
if popup then
popup.OKButton.Visible = true
popup.DeclineButton.Visible = false
popup.AcceptButton.Visible = false
end
end
function showTwoButtons()
local popup = script.Parent:FindFirstChild("Popup")
if popup then
popup.OKButton.Visible = false
popup.DeclineButton.Visible = true
popup.AcceptButton.Visible = true
end
end
if teleportEnabled then
game:GetService("TeleportService").ErrorCallback = function(message)
local popup = script.Parent:FindFirstChild("Popup")
showOneButton()
popup.PopupText.Text = message
local clickCon
clickCon = popup.OKButton.MouseButton1Click:connect(function()
if clickCon then clickCon:disconnect() end
game.GuiService:RemoveCenterDialog(script.Parent:FindFirstChild("Popup"))
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
game.GuiService:AddCenterDialog(script.Parent:FindFirstChild("Popup"), Enum.CenterDialogType.QuitDialog,
--ShowFunction
function()
showOneButton()
script.Parent:FindFirstChild("Popup").Visible = true
popup:TweenSize(UDim2.new(0,330,0,350),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true)
end,
--HideFunction
function()
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
end
game:GetService("TeleportService").ConfirmationCallback = function(message, placeId, spawnName)
local popup = script.Parent:FindFirstChild("Popup")
popup.PopupText.Text = message
popup.PopupImage.Image = ""
local yesCon, noCon
local function killCons()
if yesCon then yesCon:disconnect() end
if noCon then noCon:disconnect() end
game.GuiService:RemoveCenterDialog(script.Parent:FindFirstChild("Popup"))
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end
yesCon = popup.AcceptButton.MouseButton1Click:connect(function()
killCons()
local success, err = pcall(function() game:GetService("TeleportService"):TeleportImpl(placeId,spawnName) end)
if not success then
showOneButton()
popup.PopupText.Text = err
local clickCon
clickCon = popup.OKButton.MouseButton1Click:connect(function()
if clickCon then clickCon:disconnect() end
game.GuiService:RemoveCenterDialog(script.Parent:FindFirstChild("Popup"))
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
game.GuiService:AddCenterDialog(script.Parent:FindFirstChild("Popup"), Enum.CenterDialogType.QuitDialog,
--ShowFunction
function()
showOneButton()
script.Parent:FindFirstChild("Popup").Visible = true
popup:TweenSize(UDim2.new(0,330,0,350),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true)
end,
--HideFunction
function()
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
end
end)
noCon = popup.DeclineButton.MouseButton1Click:connect(function()
killCons()
local success = pcall(function() game:GetService("TeleportService"):TeleportCancel() end)
end)
local centerDialogSuccess = pcall(function() game.GuiService:AddCenterDialog(script.Parent:FindFirstChild("Popup"), Enum.CenterDialogType.QuitDialog,
--ShowFunction
function()
showTwoButtons()
popup.AcceptButton.Text = "Leave"
popup.DeclineButton.Text = "Stay"
script.Parent:FindFirstChild("Popup").Visible = true
popup:TweenSize(UDim2.new(0,330,0,350),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true)
end,
--HideFunction
function()
popup:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true,makePopupInvisible())
end)
end)
if centerDialogSuccess == false then
script.Parent:FindFirstChild("Popup").Visible = true
popup.AcceptButton.Text = "Leave"
popup.DeclineButton.Text = "Stay"
popup:TweenSize(UDim2.new(0,330,0,350),Enum.EasingDirection.Out,Enum.EasingStyle.Quart,1,true)
end
return true
end
end
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,72 @@
--build our gui
local popupFrame = Instance.new("Frame")
popupFrame.Position = UDim2.new(0.5,-165,0.5,-175)
popupFrame.Size = UDim2.new(0,330,0,350)
popupFrame.Style = Enum.FrameStyle.RobloxRound
popupFrame.ZIndex = 4
popupFrame.Name = "Popup"
popupFrame.Visible = false
popupFrame.Parent = script.Parent
local darken = popupFrame:clone()
darken.Size = UDim2.new(1,16,1,16)
darken.Position = UDim2.new(0,-8,0,-8)
darken.Name = "Darken"
darken.ZIndex = 1
darken.Parent = popupFrame
local acceptButton = Instance.new("TextButton")
acceptButton.Position = UDim2.new(0,20,0,270)
acceptButton.Size = UDim2.new(0,100,0,50)
acceptButton.Font = Enum.Font.ArialBold
acceptButton.FontSize = Enum.FontSize.Size24
acceptButton.Style = Enum.ButtonStyle.RobloxButton
acceptButton.TextColor3 = Color3.new(248/255,248/255,248/255)
acceptButton.Text = "Yes"
acceptButton.ZIndex = 5
acceptButton.Name = "AcceptButton"
acceptButton.Parent = popupFrame
local declineButton = acceptButton:clone()
declineButton.Position = UDim2.new(1,-120,0,270)
declineButton.Text = "No"
declineButton.Name = "DeclineButton"
declineButton.Parent = popupFrame
local okButton = acceptButton:clone()
okButton.Name = "OKButton"
okButton.Text = "OK"
okButton.Position = UDim2.new(0.5,-50,0,270)
okButton.Visible = false
okButton.Parent = popupFrame
local popupImage = Instance.new("ImageLabel")
popupImage.BackgroundTransparency = 1
popupImage.Position = UDim2.new(0.5,-140,0,0)
popupImage.Size = UDim2.new(0,280,0,280)
popupImage.ZIndex = 3
popupImage.Name = "PopupImage"
popupImage.Parent = popupFrame
local backing = Instance.new("ImageLabel")
backing.BackgroundTransparency = 1
backing.Size = UDim2.new(1,0,1,0)
backing.Image = "http://www.watrbx.wtf/asset/?id=47574181"
backing.Name = "Backing"
backing.ZIndex = 2
backing.Parent = popupImage
local popupText = Instance.new("TextLabel")
popupText.Name = "PopupText"
popupText.Size = UDim2.new(1,0,0.8,0)
popupText.Font = Enum.Font.ArialBold
popupText.FontSize = Enum.FontSize.Size36
popupText.BackgroundTransparency = 1
popupText.Text = "Hello I'm a popup"
popupText.TextColor3 = Color3.new(248/255,248/255,248/255)
popupText.TextWrap = true
popupText.ZIndex = 5
popupText.Parent = popupFrame
script:remove()
@@ -0,0 +1,999 @@
-- wait for important items to appear
while not game do
wait(0.1)
end
while not game:GetService("MarketplaceService") do
wait(0.1)
end
while not game:FindFirstChild("CoreGui") do
wait(0.1)
end
while not game.CoreGui:FindFirstChild("RobloxGui") do
wait(0.1)
end
local allowedPlaceIds = nil--{41647283, 54352498, 96623001, 100364292}
if allowedPlaceIds ~= nil then
local currentPlaceId = game.PlaceId
local canRunScript = false
for index, id in pairs(allowedPlaceIds) do
if currentPlaceId == id then
canRunScript = true
break
end
end
if not canRunScript then
script:Destroy()
return -- don't think this gets hit, but just in case return
end
end
-------------------------------- Global Variables ----------------------------------------
-- utility variables
local RbxUtility = nil
local baseUrl = game:GetService("ContentProvider").BaseUrl:lower()
-- data variables
local currentProductInfo, currentAssetId, currentCurrencyType, currentCurrencyAmount, currentEquipOnPurchase, currentProductId
local checkingPlayerFunds = false
local openBCUpSellWindowConnection = nil
-- When a player has insufficient funds to buy something, this is how often we check to see if their funds have changed (in seconds)
local checkPlayerFundsLoopTime = 5
-- gui variables
local openBuyCurrencyWindowConnection = nil
local currentlyPrompting = false
local purchaseDialog, errorDialog = nil
local tweenTime = 0.3
local showPosition = UDim2.new(0.5,-330,0.5,-200)
local hidePosition = UDim2.new(0.5,-330,1,5)
local isSmallScreen = nil
local spinning = false
local spinnerIcons = nil
local smallScreenThreshold = 450
local hereText
-- user facing images
local assetUrls = {}
local assetUrl = "http://www.watrbx.wtf/Asset/?id="
local errorImageUrl = assetUrl .. "42557901" table.insert(assetUrls, errorImageUrl)
local buyImageUrl = assetUrl .. "104651457" table.insert(assetUrls,buyImageUrl)
local buyImageDownUrl = assetUrl .. "104651515" table.insert(assetUrls, buyImageDownUrl)
local buyImageDisabledUrl = assetUrl .. "104651532" table.insert(assetUrls, buyImageDisabledUrl)
local cancelButtonImageUrl = assetUrl .. "104651592" table.insert(assetUrls, cancelButtonImageUrl)
local cancelButtonDownUrl = assetUrl .. "104651639" table.insert(assetUrls, cancelButtonDownUrl)
local okButtonUrl = assetUrl .. "104651665" table.insert(assetUrls, okButtonUrl)
local okButtonPressedrl = assetUrl .."104651707" table.insert(assetUrls, okButtonPressedrl)
local freeButtonImageUrl = assetUrl .. "104651733" table.insert(assetUrls, freeButtonImageUrl)
local freeButtonImageDownUrl = assetUrl .. "104651761" table.insert(assetUrls, freeButtonImageDownUrl)
local tixIcon = assetUrl .. "102481431" table.insert(assetUrls,tixIcon)
local robuxIcon = assetUrl .. "102481419" table.insert(assetUrls,robuxIcon)
-- user facing string
local buyHeaderText = "Buy Item"
local takeHeaderText = "Take Item"
local buyFailedHeaderText = "An Error Occurred"
local errorPurchasesDisabledText = "in-game purchases are disabled"
local errorPurchasesUnknownText = "Roblox is performing maintenance"
local purchaseSucceededText = "Your purchase of itemName succeeded!"
local purchaseFailedText = "Your purchase of itemName failed because errorReason. Your account has not been charged. Please try again soon."
local itemPurchaseText = "Would you like to buy the assetType 'itemName' for currencyType currencyAmount?"
local freeItemPurchaseText = "Would you like to take the assetType 'itemName' for FREE?"
local freeItemBalanceText = "Your balance of Robux or Tix will not be affected by this transaction."
local buildsClubUpsellText = "You don't have the appropriate membership to buy this item. Please click here to upgrade your builders club"
-------------------------------- End Global Variables ----------------------------------------
----------------------------- Util Functions ---------------------------------------------
function getSecureApiBaseUrl()
local secureApiUrl = baseUrl
secureApiUrl = string.gsub(secureApiUrl,"http","https")
secureApiUrl = string.gsub(secureApiUrl,"www","api")
return secureApiUrl
end
function getRbxUtility()
if not RbxUtility then
RbxUtility = LoadLibrary("RbxUtility")
end
return RbxUtility
end
function preloadAssets()
for i = 1, #assetUrls do
game:GetService("ContentProvider"):Preload(assetUrls[i])
end
end
----------------------------- End Util Functions ---------------------------------------------
-------------------------------- Accept/Decline Functions --------------------------------------
function removeCurrentPurchaseInfo()
currentAssetId = nil
currentCurrencyType = nil
currentCurrencyAmount = nil
currentEquipOnPurchase = nil
currentProductId = nil
currentProductInfo = nil
end
function closePurchasePrompt()
purchaseDialog:TweenPosition(hidePosition, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenTime, true, function()
game.GuiService:RemoveCenterDialog(purchaseDialog)
hidePurchasing()
purchaseDialog.Visible = false
currentlyPrompting = false
end)
end
function userPurchaseActionsEnded(isSuccess)
checkingPlayerFunds = false
if isSuccess then -- show the user we bought the item successfully, when they close this dialog we will call signalPromptEnded
local newPurchasedSucceededText = string.gsub( purchaseSucceededText,"itemName", tostring(currentProductInfo["Name"]))
purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = newPurchasedSucceededText
setButtonsVisible(purchaseDialog.BodyFrame.OkPurchasedButton)
hidePurchasing()
else -- otherwise we didn't purchase, no need to show anything, just signal and close dialog
signalPromptEnded(isSuccess)
end
end
function signalPromptEnded(isSuccess)
closePurchasePrompt()
game:GetService("MarketplaceService"):SignalPromptPurchaseFinished(game.Players.LocalPlayer, currentAssetId, isSuccess)
removeCurrentPurchaseInfo()
end
-- make sure our gui displays the proper purchase data, and set the productid we will try and buy if use specifies a buy action
function updatePurchasePromptData(toggleColoredText)
local newItemDescription = ""
if hereText then
hereText.Parent = nil
end
if not currentProductInfo then return end
-- id to use when we request a purchase
currentProductId = currentProductInfo["ProductId"]
if isFreeItem() then
newItemDescription = string.gsub( freeItemPurchaseText,"itemName", tostring(currentProductInfo["Name"]))
newItemDescription = string.gsub( newItemDescription,"assetType", tostring(assetTypeToString(currentProductInfo["AssetTypeId"])) )
setHeaderText(takeHeaderText)
else -- otherwise item costs something, so different prompt
newItemDescription = string.gsub( itemPurchaseText,"itemName", tostring(currentProductInfo["Name"]))
newItemDescription = string.gsub( newItemDescription,"assetType", tostring(assetTypeToString(currentProductInfo["AssetTypeId"])) )
newItemDescription = string.gsub( newItemDescription,"currencyType", tostring(currencyTypeToString(currentCurrencyType)) )
newItemDescription = string.gsub( newItemDescription,"currencyAmount", tostring(currentCurrencyAmount))
setHeaderText(buyHeaderText)
end
purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = newItemDescription
purchaseDialog.BodyFrame.ItemPreview.Image = baseUrl .. "thumbs/asset.ashx?assetid=" .. tostring(currentAssetId) .. '&x=100&y=100&format=png';
end
function showPurchasePrompt()
local canPurchase, insufficientFunds, notRightBC, override, descText = canPurchaseItem()
if canPurchase then
updatePurchasePromptData()
if override and descText then
purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = descText
purchaseDialog.BodyFrame.AfterBalanceButton.Visible = false
end
game.GuiService:AddCenterDialog(purchaseDialog, Enum.CenterDialogType.ModalDialog,
--ShowFunction
function()
-- set the state for our buttons
purchaseDialog.Visible = true
if isFreeItem() then
setButtonsVisible(purchaseDialog.BodyFrame.FreeButton, purchaseDialog.BodyFrame.CancelButton, purchaseDialog.BodyFrame.AfterBalanceButton)
elseif notRightBC then
purchaseDialog.BodyFrame.AfterBalanceButton.Text = "You require an upgrade to your Builders Club membership to purchase this item. Click here to upgrade."
if not openBCUpSellWindowConnection then
openBCUpSellWindowConnection = purchaseDialog.BodyFrame.AfterBalanceButton.MouseButton1Click:connect(function()
if purchaseDialog.BodyFrame.AfterBalanceButton.Text == "You require an upgrade to your Builders Club membership to purchase this item. Click here to upgrade." then
print('Upselling BC')
openBCUpSellWindow()
end
end)
end
setButtonsVisible(purchaseDialog.BodyFrame.BuyDisabledButton, purchaseDialog.BodyFrame.CancelButton, purchaseDialog.BodyFrame.AfterBalanceButton)
elseif insufficientFunds then
setButtonsVisible(purchaseDialog.BodyFrame.BuyDisabledButton, purchaseDialog.BodyFrame.CancelButton, purchaseDialog.BodyFrame.AfterBalanceButton)
elseif override then
setButtonsVisible(purchaseDialog.BodyFrame.BuyDisabledButton, purchaseDialog.BodyFrame.CancelButton) -- , purchaseDialog.BodyFrame.AfterBalanceButton)
else
setButtonsVisible(purchaseDialog.BodyFrame.BuyButton, purchaseDialog.BodyFrame.CancelButton) -- , purchaseDialog.BodyFrame.AfterBalanceButton)
end
purchaseDialog:TweenPosition(showPosition, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenTime, true)
-- funds are insufficient so we have prompted the user to buy more, now we check until the user buys or cancels
if insufficientFunds and notRightBC == false then
Spawn(function()
checkingPlayerFunds = true
checkPlayerFundLoop()
end)
end
end,
--HideFunction
function()
purchaseDialog.Visible = false
end)
else -- we failed in prompting a purchase, do a decline
doDeclinePurchase()
end
end
-- given an asset id, this function will grab that asset from the website, and return the first "Tool" object found inside it
function getToolAssetID(assetID)
local newTool = game:GetService("InsertService"):LoadAsset(assetID)
if not newTool then return nil end
if newTool:IsA("Tool") then
return newTool
end
local toolChildren = newTool:GetChildren()
for i = 1, #toolChildren do
if toolChildren[i]:IsA("Tool") then
return toolChildren[i]
end
end
return nil
end
-- the user tried to purchase by clicking the purchase button, but something went wrong.
-- let them know their account was not charged, and that they do not own the item yet.
function purchaseFailed(inGamePurchasesDisabled)
local newPurchasedFailedText = string.gsub( purchaseFailedText,"itemName", tostring(currentProductInfo["Name"]))
if inGamePurchasesDisabled then
newPurchasedFailedText = string.gsub( newPurchasedFailedText,"errorReason", tostring(errorPurchasesDisabledText) )
else
newPurchasedFailedText = string.gsub( newPurchasedFailedText,"errorReason", tostring(errorPurchasesUnknownText) )
end
purchaseDialog.BodyFrame.ItemPreview.ItemDescription.Text = newPurchasedFailedText
purchaseDialog.BodyFrame.ItemPreview.Image = errorImageUrl
setButtonsVisible(purchaseDialog.BodyFrame.OkButton)
setHeaderText(buyFailedHeaderText)
hidePurchasing()
end
-- user has specified they want to buy an item, now try to attempt to buy it for them
function doAcceptPurchase(currencyPreferredByUser)
showPurchasing() -- shows a purchasing ui (shows spinner)
-- http call to do the purchase
local response = "none"
local success, reason = ypcall(function()
response = game:HttpPostAsync(getSecureApiBaseUrl() .. "marketplace/purchase?productId=" .. tostring(currentProductId) ..
"&currencyTypeId=" .. tostring(currencyEnumToInt(currentCurrencyType)) ..
"&purchasePrice=" .. tostring(currentCurrencyAmount) ..
"&locationType=Game" .. "&locationId=" .. Game.PlaceId,
"RobloxPurchaseRequest")
end)
-- debug output for us (found in the logs from local)
print("doAcceptPurchase success from ypcall is ",success,"reason is",reason)
print("doAcceptPurchase response is ",response)
wait(1) -- allow the purchasing waiting dialog to at least be readable (otherwise it might flash, looks bad)...
-- check to make sure purchase actually happened on the web end
if response == "none" or response == nil or response == '' then
print("did not get a proper response from web on purchase of",currentAssetId)
purchaseFailed()
return
end
-- parse our response, decide how to react
response = getRbxUtility().DecodeJSON(response)
if response then
if response["success"] == false then
if response["status"] ~= "AlreadyOwned" then
print("web return response of fail on purchase of",currentAssetId)
purchaseFailed( (response["status"] == "EconomyDisabled") )
return
end
end
else
print("web return response of non parsable JSON on purchase of",currentAssetId)
purchaseFailed()
return
end
-- check to see if this item was bought, and if we want to equip it (also need to make sure the asset type was gear)
if currentEquipOnPurchase and success and tonumber(currentProductInfo["AssetTypeId"]) == 19 then
local tool = getToolAssetID(tonumber(currentAssetId))
if tool then
tool.Parent = game.Players.LocalPlayer.Backpack
end
end
userPurchaseActionsEnded(success)
end
-- user pressed the cancel button, just remove all purchasing prompts
function doDeclinePurchase()
userPurchaseActionsEnded(false)
end
-------------------------------- End Accept/Decline Functions --------------------------------------
---------------------------------------------- Currency Functions ---------------------------------------------
-- enums have no implicit conversion to numbers in lua, has to have a function to do this
function currencyEnumToInt(currencyEnum)
if currencyEnum == Enum.CurrencyType.Robux then
return 1
elseif currencyEnum == Enum.CurrencyType.Tix then
return 2
end
end
-- oi, this is ugly
function assetTypeToString(assetType)
if assetType == 1 then return "Image"
elseif assetType == 2 then return "T-Shirt"
elseif assetType == 3 then return "Audio"
elseif assetType == 4 then return "Mesh"
elseif assetType == 5 then return "Lua"
elseif assetType == 6 then return "HTML"
elseif assetType == 7 then return "Text"
elseif assetType == 8 then return "Hat"
elseif assetType == 9 then return "Place"
elseif assetType == 10 then return "Model"
elseif assetType == 11 then return "Shirt"
elseif assetType == 12 then return "Pants"
elseif assetType == 13 then return "Decal"
elseif assetType == 16 then return "Avatar"
elseif assetType == 17 then return "Head"
elseif assetType == 18 then return "Face"
elseif assetType == 19 then return "Gear"
elseif assetType == 21 then return "Badge"
elseif assetType == 22 then return "Group Emblem"
elseif assetType == 24 then return "Animation"
elseif assetType == 25 then return "Arms"
elseif assetType == 26 then return "Legs"
elseif assetType == 27 then return "Torso"
elseif assetType == 28 then return "Right Arm"
elseif assetType == 29 then return "Left Arm"
elseif assetType == 30 then return "Left Leg"
elseif assetType == 31 then return "Right Leg"
elseif assetType == 32 then return "Package"
elseif assetType == 33 then return "YouTube Video"
elseif assetType == 34 then return "Game Pass"
end
return ""
end
function currencyTypeToString(currencyType)
if currencyType == Enum.CurrencyType.Tix then
return "Tix"
else
return "R$"
end
end
-- figure out what currency to use based on the currency you can actually sell the item in and what the script specified
function setCurrencyAmountAndType(priceInRobux, priceInTix)
if currentCurrencyType == Enum.CurrencyType.Default or currentCurrencyType == Enum.CurrencyType.Robux then -- sell for default (user doesn't care) or robux
if priceInRobux ~= nil and priceInRobux ~= 0 then -- we can sell for robux
currentCurrencyAmount = priceInRobux
currentCurrencyType = Enum.CurrencyType.Robux
else -- have to use tix
currentCurrencyAmount = priceInTix
currentCurrencyType = Enum.CurrencyType.Tix
end
elseif currentCurrencyType == Enum.CurrencyType.Tix then -- we want to sell for tix
if priceInTix ~= nil and priceInTix ~= 0 then -- we can sell for tix
currentCurrencyAmount = priceInTix
currentCurrencyType = Enum.CurrencyType.Tix
else -- have to use robux
currentCurrencyAmount = priceInRobux
currentCurrencyType = Enum.CurrencyType.Robux
end
else
return false
end
if currentCurrencyAmount == nil then
return false
end
return true
end
-- will get the player's balance of robux and tix, return in a table
function getPlayerBalance()
local playerBalance = nil
local success, errorCode = ypcall(function() playerBalance = game:HttpGetAsync(getSecureApiBaseUrl() .. "currency/balance") end)
if not success then
print("Get player balance failed because",errorCode)
return nil
end
if playerBalance == '' then
return nil
end
playerBalance = getRbxUtility().DecodeJSON(playerBalance)
return playerBalance
end
-- should open an external default browser window to this url
function openBuyCurrencyWindow()
game:GetService("GuiService"):OpenBrowserWindow(baseUrl .. "Upgrades/Robux.aspx")
end
function openBCUpSellWindow()
Game:GetService('GuiService'):OpenBrowserWindow(baseUrl .. "Upgrades/BuildersClubMemberships.aspx")
end
-- set up the gui text at the bottom of the prompt (alerts user to how much money they will have left, or if they need to buy more to buy the item)
function updateAfterBalanceText(playerBalance, notRightBc)
if isFreeItem() then
purchaseDialog.BodyFrame.AfterBalanceButton.Text = freeItemBalanceText
return true, false
end
local keyWord = nil
if currentCurrencyType == Enum.CurrencyType.Robux then
keyWord = "robux"
elseif currentCurrencyType == Enum.CurrencyType.Tix then
keyWord = "tickets"
end
if not keyWord then
return false
end
local playerBalanceNumber = tonumber(playerBalance[keyWord])
if not playerBalanceNumber then
return false
end
local afterBalanceNumber = playerBalanceNumber - currentCurrencyAmount
-- check to see if we have enough of the desired currency to allow a purchase, if not we need to prompt user to buy robux
if not notRightBc then
if afterBalanceNumber < 0 and keyWord == "robux" then
if openBuyCurrencyWindowConnection == nil then
openBuyCurrencyWindowConnection = purchaseDialog.BodyFrame.AfterBalanceButton.MouseButton1Click:connect(openBuyCurrencyWindow)
end
purchaseDialog.BodyFrame.AfterBalanceButton.Text = "You need " .. currencyTypeToString(currentCurrencyType) .. " " .. tostring(-afterBalanceNumber) .. " more to buy this, click here to purchase more."
return true, true
elseif afterBalanceNumber < 0 and keyWord == "tickets" then
purchaseDialog.BodyFrame.AfterBalanceButton.Text = "You need " .. tostring(-afterBalanceNumber) .. " " .. currencyTypeToString(currentCurrencyType) .. " more to buy this item."
return true, true -- user can't buy more tickets, so we say fail the transaction (maybe instead we can prompt them to trade currency???)
end
end
-- this ensures that we only have one connection to openBuyCurrencyWindow at a time (otherwise might open multiple browser windows)
if(openBuyCurrencyWindowConnection) then
openBuyCurrencyWindowConnection:disconnect()
openBuyCurrencyWindowConnection = nil
end
purchaseDialog.BodyFrame.AfterBalanceButton.Text = "Your balance after this transaction will be " .. currencyTypeToString(currentCurrencyType) .. " " .. tostring(afterBalanceNumber) .. "."
return true, false
end
function isFreeItem()
-- if both of these are true, then the item is free, just prompt user if they want to take one
return currentProductInfo and currentProductInfo["IsForSale"] == true and currentProductInfo["IsPublicDomain"] == true
end
-- will continuously poll the player to see if funds have changed. Poll rate is changed by adjusting checkPlayerFundsLoopTime, which is specified in seconds
function checkPlayerFundLoop()
local canPurchase = true
local insufficientFunds = true
while checkingPlayerFunds and insufficientFunds do
wait(checkPlayerFundsLoopTime)
canPurchase, insufficientFunds = canPurchaseItem() -- check again to see if we can buy item
if canPurchase then
if not insufficientFunds then
-- we can buy item! set our buttons up and we will exit this loop
setButtonsVisible(purchaseDialog.BodyFrame.BuyButton,purchaseDialog.BodyFrame.CancelButton, purchaseDialog.BodyFrame.AfterBalanceButton)
end
end
end
end
---------------------------------------------- End Currency Functions ---------------------------------------------
---------------------------------------------- Data Functions -----------------------------------------------------
-- more enum to int fun!
function membershipTypeToNumber(membership)
if membership == Enum.MembershipType.None then
return 0
elseif membership == Enum.MembershipType.BuildersClub then
return 1
elseif membership == Enum.MembershipType.TurboBuildersClub then
return 2
elseif membership == Enum.MembershipType.OutrageousBuildersClub then
return 3
end
return -1
end
-- This functions checks to make sure the purchase is even possible, if not it returns false and we don't prompt user (some situations require user feedback when we won't prompt)
function canPurchaseItem()
-- first we see if player already owns the asset
local playerOwnsAsset = false
local notRightBc = false
local descText = nil
local success, errorCode = ypcall(function() playerOwnsAsset = game:HttpGetAsync(getSecureApiBaseUrl()
.. "/ownership/hasAsset?userId="
.. tostring(game.Players.LocalPlayer.userId)
.. "&assetId=" .. tostring(currentAssetId))
end)
if not success then
print("could not tell if player owns asset because",errorCode)
return false
end
purchaseDialog.BodyFrame.AfterBalanceButton.Visible = true
-- next we get the product info and do some checks on that
local success = ypcall(function() currentProductInfo = game:GetService("MarketplaceService"):GetProductInfo(currentAssetId) end)
if currentProductInfo == nil or not success then
descText = "In-game sales are temporarily disabled. Please try again later."
return true, nil, nil, true, descText
end
if type(currentProductInfo) ~= "table" then
currentProductInfo = getRbxUtility().DecodeJSON(currentProductInfo)
end
if not currentProductInfo then
descText = "Could not get product info. Please try again later."
return true, nil, nil, true, descText
end
if playerOwnsAsset == true or playerOwnsAsset == "true" then
descText = "You already own this item."
return true, nil, nil, true, descText
end
if currentProductInfo["IsForSale"] == false and currentProductInfo["IsPublicDomain"] == false then
descText = "This item is no longer for sale."
return true, nil, nil, true, descText
end
-- now we start talking money, making sure we are going to be able to purchase this
if not setCurrencyAmountAndType(tonumber(currentProductInfo["PriceInRobux"]), tonumber(currentProductInfo["PriceInTickets"])) then
descText = "We could retrieve the price of the item correctly. Please try again later."
return true, nil, nil, true, descText
end
local playerBalance = getPlayerBalance()
if not playerBalance then
descText = "Could not retrieve your balance. Please try again later."
return true, nil, nil, true, descText
end
if tonumber(currentProductInfo["MinimumMembershipLevel"]) > membershipTypeToNumber(game.Players.LocalPlayer.MembershipType) then
notRightBc = true
end
local updatedBalance, insufficientFunds = updateAfterBalanceText(playerBalance, notRightBc)
if notRightBc then
purchaseDialog.BodyFrame.AfterBalanceButton.Active = true
return true, insufficientFunds, notRightBc, false
end
if currentProductInfo["ContentRatingTypeId"] == 1 then
if game.Players.LocalPlayer:GetUnder13() then
descText = "Your account is under 13 so purchase of this item is not allowed."
return true, nil, nil, true, descText
end
end
if (currentProductInfo["IsLimited"] == true or currentProductInfo["IsLimitedUnique"] == true) and
(currentProductInfo["Remaining"] == "" or currentProductInfo["Remaining"] == 0 or currentProductInfo["Remaining"] == nil) then
descText = "All copies of this item have been sold out! Try buying from other users on the website."
return true, nil, nil, true, descText
end
if not updatedBalance then
descText = 'Could not update your balance. Please check back after some time.'
return true, nil, nil, true, descText
end
-- we use insufficient funds to display a prompt to buy more robux
purchaseDialog.BodyFrame.AfterBalanceButton.Active = true
return true, insufficientFunds
end
function computeSpaceString(pLabel)
local nString = " "
local tempSpaceLabel = Instance.new('TextButton')
tempSpaceLabel.Size = UDim2.new(0, pLabel.AbsoluteSize.X, 0, pLabel.AbsoluteSize.Y);
tempSpaceLabel.FontSize = pLabel.FontSize;
tempSpaceLabel.Parent = pLabel.Parent;
tempSpaceLabel.BackgroundTransparency = 1.0;
tempSpaceLabel.Text = nString;
tempSpaceLabel.Name = 'SpaceButton'
while tempSpaceLabel.TextBounds.X < pLabel.TextBounds.X do
nString = nString .. " "
tempSpaceLabel.Text = nString
end
nString = nString .. " "
tempSpaceLabel.Text = ""
return nString
end
---------------------------------------------- End Data Functions -----------------------------------------------------
---------------------------------------------- Gui Functions ----------------------------------------------
function startSpinner()
spinning = true
Spawn( function()
local spinPos = 0
while spinning do
local pos = 0
while pos < 8 do
if pos == spinPos or pos == ((spinPos+1)%8) then
spinnerIcons[pos+1].Image = "http://www.watrbx.wtf/Asset?id=45880668"
else
spinnerIcons[pos+1].Image = "http://www.watrbx.wtf/Asset?id=45880710"
end
pos = pos + 1
end
spinPos = (spinPos + 1) % 8
wait(1/15)
end
end)
end
function stopSpinner()
spinning = false
end
-- convenience method to say exactly what buttons should be visible (all others are not!)
function setButtonsVisible(...)
local args = {...}
local argCount = select('#', ...)
local bodyFrameChildren = purchaseDialog.BodyFrame:GetChildren()
for i = 1, #bodyFrameChildren do
if bodyFrameChildren[i]:IsA("GuiButton") then
bodyFrameChildren[i].Visible = false
for j = 1, argCount do
if bodyFrameChildren[i] == args[j] then
bodyFrameChildren[i].Visible = true
break
end
end
end
end
end
-- used for the "Purchasing..." frame
function createSpinner(size,position,parent)
local spinnerFrame = Instance.new("Frame")
spinnerFrame.Name = "Spinner"
spinnerFrame.Size = size
spinnerFrame.Position = position
spinnerFrame.BackgroundTransparency = 1
spinnerFrame.ZIndex = 10
spinnerFrame.Parent = parent
spinnerIcons = {}
local spinnerNum = 1
while spinnerNum <= 8 do
local spinnerImage = Instance.new("ImageLabel")
spinnerImage.Name = "Spinner"..spinnerNum
spinnerImage.Size = UDim2.new(0, 16, 0, 16)
spinnerImage.Position = UDim2.new(.5+.3*math.cos(math.rad(45*spinnerNum)), -8, .5+.3*math.sin(math.rad(45*spinnerNum)), -8)
spinnerImage.BackgroundTransparency = 1
spinnerImage.ZIndex = 10
spinnerImage.Image = "http://www.watrbx.wtf/Asset/?id=45880710"
spinnerImage.Parent = spinnerFrame
spinnerIcons[spinnerNum] = spinnerImage
spinnerNum = spinnerNum + 1
end
end
-- all the gui init. Would be nice if this didn't have to be a script
function createPurchasePromptGui()
purchaseDialog = Instance.new("Frame")
purchaseDialog.Name = "PurchaseFrame"
purchaseDialog.Size = UDim2.new(0,660,0,400)
purchaseDialog.Position = hidePosition
purchaseDialog.Visible = false
purchaseDialog.BackgroundColor3 = Color3.new(141/255,141/255,141/255)
purchaseDialog.BorderColor3 = Color3.new(204/255,204/255,204/255)
purchaseDialog.Parent = game.CoreGui.RobloxGui
local bodyFrame = Instance.new("Frame")
bodyFrame.Name = "BodyFrame"
bodyFrame.Size = UDim2.new(1,0,1,-60)
bodyFrame.Position = UDim2.new(0,0,0,60)
bodyFrame.BackgroundColor3 = Color3.new(67/255, 67/255, 67/255)
bodyFrame.BorderSizePixel = 0
bodyFrame.Parent = purchaseDialog
local titleLabel = createTextObject("TitleLabel", "Buy Item", "TextLabel", Enum.FontSize.Size48)
titleLabel.Size = UDim2.new(1,0,0,60)
local titleBackdrop = titleLabel:Clone()
titleBackdrop.Name = "TitleBackdrop"
titleBackdrop.TextColor3 = Color3.new(32/255,32/255,32/255)
titleBackdrop.BackgroundTransparency = 0.0
titleBackdrop.BackgroundColor3 = Color3.new(54/255, 96/255, 171/255)
titleBackdrop.Position = UDim2.new(0,0,0,-2)
titleBackdrop.Parent = purchaseDialog
titleLabel.Parent = purchaseDialog
local cancelButton = createImageButton("CancelButton")
cancelButton.Position = UDim2.new(0.75,-70,1,-120)
cancelButton.BackgroundTransparency = 1
cancelButton.BorderSizePixel = 0
cancelButton.Parent = bodyFrame
cancelButton.Modal = true
cancelButton.Image = cancelButtonImageUrl
cancelButton.MouseButton1Down:connect(function()
cancelButton.Image = cancelButtonDownUrl
end)
cancelButton.MouseButton1Up:connect(function( )
cancelButton.Image = cancelButtonImageUrl
end)
cancelButton.MouseLeave:connect(function( )
cancelButton.Image = cancelButtonImageUrl
end)
cancelButton.MouseButton1Click:connect(doDeclinePurchase)
local buyButton = createImageButton("BuyButton")
buyButton.Position = UDim2.new(0.25,-100,1,-120)
buyButton.BackgroundTransparency = 1
buyButton.BorderSizePixel = 0
buyButton.Image = buyImageUrl
buyButton.MouseButton1Down:connect(function()
buyButton.Image = buyImageDownUrl
end)
buyButton.MouseButton1Up:connect(function( )
buyButton.Image = buyImageUrl
end)
buyButton.MouseLeave:connect(function( )
buyButton.Image = buyImageUrl
end)
buyButton.Parent = bodyFrame
local buyDisabledButton = buyButton:Clone()
buyDisabledButton.Name = "BuyDisabledButton"
buyDisabledButton.AutoButtonColor = false
buyDisabledButton.Visible = false
buyDisabledButton.Active = false
buyDisabledButton.Image = buyImageDisabledUrl
buyDisabledButton.Parent = bodyFrame
local freeButton = buyButton:Clone()
freeButton.BackgroundTransparency = 1
freeButton.Name = "FreeButton"
freeButton.Visible = false
freeButton.Image = freeButtonImageUrl
freeButton.MouseButton1Down:connect(function()
freeButton.Image = freeButtonImageDownUrl
end)
freeButton.MouseButton1Up:connect(function( )
freeButton.Image = freeButtonImageUrl
end)
freeButton.MouseLeave:connect(function( )
freeButton.Image = freeButtonImageUrl
end)
freeButton.Parent = bodyFrame
local okButton = buyButton:Clone()
okButton.Name = "OkButton"
okButton.BackgroundTransparency = 1
okButton.Visible = false
okButton.Position = UDim2.new(0.5,-okButton.Size.X.Offset/2,1,-120)
okButton.Modal = true
okButton.Image = okButtonUrl
okButton.MouseButton1Down:connect(function()
okButton.Image = okButtonPressedrl
end)
okButton.MouseButton1Up:connect(function( )
okButton.Image = okButtonUrl
end)
okButton.MouseLeave:connect(function( )
okButton.Image = okButtonUrl
end)
okButton.Parent = bodyFrame
local okPurchasedButton = okButton:Clone()
okPurchasedButton.Name = "OkPurchasedButton"
okPurchasedButton.MouseButton1Down:connect(function()
okPurchasedButton.Image = okButtonPressedrl
end)
okPurchasedButton.MouseButton1Up:connect(function( )
okPurchasedButton.Image = okButtonUrl
end)
okPurchasedButton.MouseLeave:connect(function( )
okPurchasedButton.Image = okButtonUrl
end)
okPurchasedButton.Parent = bodyFrame
okButton.MouseButton1Click:connect(function () userPurchaseActionsEnded(false) end)
okPurchasedButton.MouseButton1Click:connect(function() signalPromptEnded(true) end)
buyButton.MouseButton1Click:connect(function() doAcceptPurchase(Enum.CurrencyType.Robux) end)
freeButton.MouseButton1Click:connect(function() doAcceptPurchase(false) end)
local itemPreview = Instance.new("ImageLabel")
itemPreview.Name = "ItemPreview"
itemPreview.BackgroundColor3 = Color3.new(32/255,32/255,32/255)
itemPreview.BorderColor3 = Color3.new(141/255,141/255,141/255)
itemPreview.Position = UDim2.new(0,30,0,20)
itemPreview.Size = UDim2.new(0,180,0,180)
itemPreview.ZIndex = 2
itemPreview.Parent = bodyFrame
local itemDescription = createTextObject("ItemDescription", "Would you like to buy the 'itemName' for currencyType currencyAmount?","TextLabel",Enum.FontSize.Size24)
itemDescription.Position = UDim2.new(1,20,0,0)
itemDescription.Size = UDim2.new(0,410,1,0)
itemDescription.Parent = itemPreview
local afterBalanceButton = createTextObject("AfterBalanceButton","Place holder text ip sum lorem dodo ashs","TextButton",Enum.FontSize.Size24)
afterBalanceButton.AutoButtonColor = false
afterBalanceButton.Position = UDim2.new(0,5,1,-55)
afterBalanceButton.Size = UDim2.new(1,-10,0,50)
afterBalanceButton.Parent = bodyFrame
local purchasingFrame = Instance.new("Frame")
purchasingFrame.Name = "PurchasingFrame"
purchasingFrame.Size = UDim2.new(1,0,1,0)
purchasingFrame.BackgroundColor3 = Color3.new(0,0,0)
purchasingFrame.BackgroundTransparency = 0.2
purchasingFrame.BorderSizePixel = 0
purchasingFrame.ZIndex = 9
purchasingFrame.Visible = false
purchasingFrame.Active = true
purchasingFrame.Parent = purchaseDialog
local purchasingLabel = createTextObject("PurchasingLabel","Purchasing...","TextLabel",Enum.FontSize.Size48)
purchasingLabel.Size = UDim2.new(1,0,1,0)
purchasingLabel.ZIndex = 10
purchasingLabel.Parent = purchasingFrame
createSpinner(UDim2.new(0,50,0,50), UDim2.new(0.5,-25,0.5,30), purchasingLabel)
end
-- next two functions control the "Purchasing..." overlay
function showPurchasing()
startSpinner()
purchaseDialog.PurchasingFrame.Visible = true
end
function hidePurchasing()
purchaseDialog.PurchasingFrame.Visible = false
stopSpinner()
end
-- next 2 functions are convenienvce creation functions for guis
function createTextObject(name, text, type, size)
local textLabel = Instance.new(type)
textLabel.Font = Enum.Font.ArialBold
textLabel.TextColor3 = Color3.new(217/255, 217/255, 217/255)
textLabel.TextWrapped = true
textLabel.Name = name
textLabel.Text = text
textLabel.BackgroundTransparency = 1
textLabel.BorderSizePixel = 0
textLabel.FontSize = size
return textLabel
end
function createImageButton(name)
local imageButton = Instance.new("ImageButton")
imageButton.Size = UDim2.new(0,153,0,46)
imageButton.Name = name
return imageButton
end
function setHeaderText(text)
purchaseDialog.TitleLabel.Text = text
purchaseDialog.TitleBackdrop.Text = text
end
function cutSizeInHalfRecursive(instance)
-- todo: change the gui size based on how much space we have
--[[changeSize(instance,0.5)
local children = instance:GetChildren()
for i = 1, #children do
cutSizeInHalfRecursive(children[i])
end]]
end
function doubleSizeRecursive(instance)
-- todo: change the gui size based on how much space we have
--[[changeSize(instance,2)
local children = instance:GetChildren()
for i = 1, #children do
doubleSizeRecursive(children[i])
end]]
end
function modifyForSmallScreen()
cutSizeInHalfRecursive(purchaseDialog)
end
function modifyForLargeScreen()
doubleSizeRecursive(purchaseDialog)
end
-- depending on screen size, we need to change the gui
function changeGuiToScreenSize(smallScreen)
if smallScreen then
modifyForSmallScreen()
else
modifyForLargeScreen()
end
end
---------------------------------------------- End Gui Functions ----------------------------------------------
---------------------------------------------- Script Event start/initialization ----------------------------------------------
preloadAssets()
game:GetService("MarketplaceService").PromptPurchaseRequested:connect(function(player, assetId, equipIfPurchased, currencyType)
if not purchaseDialog then
createPurchasePromptGui()
end
if player == game.Players.LocalPlayer then
if currentlyPrompting then return end
currentlyPrompting = true
currentAssetId = assetId
currentCurrencyType = currencyType
currentEquipOnPurchase = equipIfPurchased
showPurchasePrompt()
end
end)
game.CoreGui.RobloxGui.Changed:connect(function()
local nowIsSmallScreen = (game.CoreGui.RobloxGui.AbsoluteSize.Y <= smallScreenThreshold)
if nowIsSmallScreen and not isSmallScreen then
changeGuiToScreenSize(true)
elseif not nowIsSmallScreen and isSmallScreen then
changeGuiToScreenSize(false)
end
isSmallScreen = nowIsSmallScreen
end)
isSmallScreen = (game.CoreGui.RobloxGui.AbsoluteSize.Y <= smallScreenThreshold)
if isSmallScreen then
changeGuiToScreenSize(true)
end
@@ -0,0 +1,23 @@
local t = {}
t.Foo =
function()
print("foo")
end
t.Bar =
function()
print("bar")
end
t.Help =
function(funcNameOrFunc)
--input argument can be a string or a function. Should return a description (of arguments and expected side effects)
if funcNameOrFunc == "Foo" or funcNameOrFunc == t.Foo then
return "Function Foo. Arguments: None. Side effect: prints foo"
elseif funcNameOrFunc == "Bar" or funcNameOrFunc == t.Bar then
return "Function Bar. Arguments: None. Side effect: prints bar"
end
end
return t
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,326 @@
-- Creates all neccessary scripts for the gui on initial load, everything except build tools
-- Created by Ben T. 10/29/10
-- Please note that these are loaded in a specific order to diminish errors/perceived load time by user
touchEnabled = false
local scriptContext = game:GetService("ScriptContext")
pcall(function() touchEnabled = game:GetService("UserInputService").TouchEnabled end)
local RobloxGui = game:GetService("CoreGui"):WaitForChild("RobloxGui")
game:SetMessage("Loading...")
-- library registration
print("Loading Modules...")
scriptContext:AddCoreScriptLocal("CoreScripts/2013/ModuleRegistration", RobloxGui)
local function waitForChild(instance, name)
while not instance:FindFirstChild(name) do
print('(SS): Waiting for ...', instance, name)
instance.ChildAdded:wait()
end
end
local function waitForProperty(instance, property)
while not instance[property] do
instance.Changed:wait()
end
end
-- Responsible for tracking logging items
local scriptContext = game:GetService("ScriptContext")
scriptContext:AddCoreScriptLocal("CoreScripts/2013/Sections", RobloxGui)
waitForChild(game:GetService("CoreGui"),"RobloxGui")
local screenGui = game:GetService("CoreGui"):FindFirstChild("RobloxGui")
if not touchEnabled then
-- ToolTipper (creates tool tips for gui)
scriptContext:AddCoreScriptLocal("CoreScripts/2013/ToolTip", RobloxGui)
-- SettingsScript
scriptContext:AddCoreScriptLocal("CoreScripts/2013/Settings", RobloxGui)
end
-- MainBotChatScript
scriptContext:AddCoreScriptLocal("CoreScripts/2013/MainBotChatScript", RobloxGui)
-- Popup Script
scriptContext:AddCoreScriptLocal("CoreScripts/2013/PopupScript", RobloxGui)
-- Friend Notification Script (probably can use this script to expand out to other notifications)
scriptContext:AddCoreScriptLocal("CoreScripts/2013/NotificationScript", RobloxGui)
-- Chat script
scriptContext:AddCoreScriptLocal("CoreScripts/2013/ChatScript", screenGui)
-- Purchase Prompt Script
scriptContext:AddCoreScriptLocal("CoreScripts/2013/PurchasePromptScript", RobloxGui)
--[[
This script controls the gui the player sees in regards to his or her health.
Can be turned with Game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
Copyright ROBLOX 2014. Written by Ben Tkacheff.
--]]
---------------------------------------------------------------------
-- Initialize/Variables
while not Game do
wait(1/60)
end
while not Game.Players do
wait(1/60)
end
local useCoreHealthBar = false
local success = pcall(function() useCoreHealthBar = Game.Players:GetUseCoreScriptHealthBar() end)
if not success or not useCoreHealthBar then
return
end
local currentHumanoid = nil
local HealthGui = nil
local lastHealth = 100
local HealthPercentageForOverlay = 5
local maxBarTweenTime = 0.3
local guiEnabled = false
local healthChangedConnection = nil
local humanoidDiedConnection = nil
local characterAddedConnection = nil
local greenBarImage = "http://www.watrbx.wtf/asset/?id=35238053"
local redBarImage = "http://www.watrbx.wtf/asset/?id=35238036"
local hurtOverlayImage = "http://www.watrbx.wtf/asset/?id=34854607"
Game:GetService("ContentProvider"):Preload(greenBarImage)
Game:GetService("ContentProvider"):Preload(redBarImage)
Game:GetService("ContentProvider"):Preload(hurtOverlayImage)
while not Game.Players.LocalPlayer do
wait(1/60)
end
---------------------------------------------------------------------
-- Functions
function CreateGui()
if HealthGui then
HealthGui.Parent = Game.CoreGui.RobloxGui
return
end
HealthGui = Instance.new("Frame")
HealthGui.Name = "HealthGui"
HealthGui.BackgroundTransparency = 1
HealthGui.Size = UDim2.new(1,0,1,0)
local hurtOverlay = Instance.new("ImageLabel")
hurtOverlay.Name = "HurtOverlay"
hurtOverlay.BackgroundTransparency = 1
hurtOverlay.Image = hurtOverlayImage
hurtOverlay.Position = UDim2.new(-10,0,-10,0)
hurtOverlay.Size = UDim2.new(20,0,20,0)
hurtOverlay.Visible = false
hurtOverlay.Parent = HealthGui
local healthFrame = Instance.new("Frame")
healthFrame.Name = "HealthFrame"
healthFrame.BackgroundColor3 = Color3.new(0,0,0)
healthFrame.BorderColor3 = Color3.new(0,0,0)
healthFrame.Position = UDim2.new(0.5,-85,1,-22)
healthFrame.Size = UDim2.new(0,170,0,18)
healthFrame.Parent = HealthGui
local healthBar = Instance.new("ImageLabel")
healthBar.Name = "HealthBar"
healthBar.BackgroundTransparency = 1
healthBar.Image = greenBarImage
healthBar.Size = UDim2.new(1,0,1,0)
healthBar.Parent = healthFrame
local healthLabel = Instance.new("TextLabel")
healthLabel.Name = "HealthLabel"
healthLabel.Text = "Health " -- gives room at end of health bar
healthLabel.Font = Enum.Font.SourceSansBold
healthLabel.FontSize = Enum.FontSize.Size14
healthLabel.TextColor3 = Color3.new(1,1,1)
healthLabel.TextStrokeTransparency = 0
healthLabel.TextXAlignment = Enum.TextXAlignment.Right
healthLabel.BackgroundTransparency = 1
healthLabel.Size = UDim2.new(1,0,1,0)
healthLabel.Parent = healthFrame
HealthGui.Parent = Game.CoreGui.RobloxGui
end
function UpdateGui(health)
if not HealthGui then return end
local healthFrame = HealthGui:FindFirstChild("HealthFrame")
if not healthFrame then return end
local healthBar = healthFrame:FindFirstChild("HealthBar")
if not healthBar then return end
-- If more than 1/4 health, bar = green. Else, bar = red.
if (health/currentHumanoid.MaxHealth) > 0.25 then
healthBar.Image = greenBarImage
else
healthBar.Image = redBarImage
end
local width = (health / currentHumanoid.MaxHealth)
width = math.max(math.min(width,1),0) -- make sure width is between 0 and 1
local healthDelta = lastHealth - health
lastHealth = health
local percentOfTotalHealth = math.abs(healthDelta/currentHumanoid.MaxHealth)
percentOfTotalHealth = math.max(math.min(percentOfTotalHealth,1),0) -- make sure percentOfTotalHealth is between 0 and 1
local newHealthSize = UDim2.new(width,0,1,0)
healthBar:TweenSize(newHealthSize, Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, percentOfTotalHealth * maxBarTweenTime, true)
local thresholdForHurtOverlay = currentHumanoid.MaxHealth * (HealthPercentageForOverlay/100)
if healthDelta >= thresholdForHurtOverlay then
AnimateHurtOverlay()
end
end
function AnimateHurtOverlay()
if not HealthGui then return end
local overlay = HealthGui:FindFirstChild("HurtOverlay")
if not overlay then return end
-- stop any tweens on overlay
overlay:TweenSizeAndPosition(UDim2.new(20, 0, 20, 0), UDim2.new(-10, 0, -10, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,0,true,function()
-- show the gui
overlay.Size = UDim2.new(1,0,1,0)
overlay.Position = UDim2.new(0,0,0,0)
overlay.Visible = true
-- now tween the hide
overlay:TweenSizeAndPosition(UDim2.new(20, 0, 20, 0) ,UDim2.new(-10, 0, -10, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,10,false,function()
overlay.Visible = false
end)
end)
end
function humanoidDied()
UpdateGui(0)
end
function disconnectPlayerConnections()
humanoidDiedConnection:disconnect()
healthChangedConnection:disconnect()
characterAddedConnection:disconnect()
end
function newPlayerCharacter()
disconnectPlayerConnections()
startGui()
end
function startGui()
local character = Game.Players.LocalPlayer.Character
while (character == nil) do
character = Game.Players.LocalPlayer.Character
wait(1/30)
end
currentHumanoid = character:WaitForChild("Humanoid")
if currentHumanoid then
CreateGui()
healthChangedConnection = currentHumanoid.HealthChanged:connect(UpdateGui)
humanoidDiedConnection = currentHumanoid.Died:connect(humanoidDied)
end
UpdateGui(currentHumanoid.Health)
characterAddedConnection = Game.Players.LocalPlayer.CharacterAdded:connect(newPlayerCharacter)
end
---------------------------------------------------------------------
-- Start Script
if Game.StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
guiEnabled = true
startGui()
end
Game.StarterGui.CoreGuiChangedSignal:connect(function(coreGuiType,enabled)
if guiEnabled and not enabled then
if HealthGui then
HealthGui.Parent = nil
end
disconnectPlayerConnections()
elseif not guiEnabled and enabled then
startGui()
end
guiEnabled = enabled
end)
if not touchEnabled then
-- New Player List
scriptContext:AddCoreScriptLocal("CoreScripts/2013/PlayerListScript", RobloxGui)
elseif screenGui.AbsoluteSize.Y > 600 then
-- New Player List
scriptContext:AddCoreScriptLocal("CoreScripts/2013/PlayerListScript",RobloxGui)
else
delay(5, function()
if RobloxGui.AbsoluteSize.Y >= 600 then
-- New Player List
scriptContext:AddCoreScriptLocal("CoreScripts/2013/PlayerListScript", RobloxGui)
end
end)
end
-- Backpack Builder, creates most of the backpack gui
scriptContext:AddCoreScriptLocal("CoreScripts/2013/BackpackScripts/BackpackBuilder", RobloxGui)
waitForChild(RobloxGui, "CurrentLoadout")
waitForChild(RobloxGui, "Backpack")
local Backpack = RobloxGui.Backpack
game:GetService("ScriptContext"):AddCoreScriptLocal("CoreScripts/2013/BackpackScripts/BackpackManager", Backpack)
-- Backpack Gear (handles all backpack gear tab stuff)
game:GetService("ScriptContext"):AddCoreScriptLocal("CoreScripts/2013/BackpackScripts/BackpackGear", Backpack)
-- Loadout Script, used for gear hotkeys
scriptContext:AddCoreScriptLocal("CoreScripts/2013/BackpackScripts/LoadoutScript", RobloxGui.CurrentLoadout)
--scriptContext:AddCoreScriptLocal("CoreScripts/BackpackScripts/BackpackWardrobe", Backpack)
local IsPersonalServer = not not game.Workspace:FindFirstChild("PSVariable")
if IsPersonalServer then
end
game.Workspace.ChildAdded:connect(function(nchild)
if nchild.Name=='PSVariable' and nchild:IsA('BoolValue') then
IsPersonalServer = true
end
end)
if touchEnabled then -- touch devices don't use same control frame
waitForChild(screenGui, "ControlFrame")
waitForChild(screenGui.ControlFrame, 'BottomLeftControl')
screenGui.ControlFrame.BottomLeftControl.Visible = false
waitForChild(screenGui.ControlFrame, 'TopLeftControl')
screenGui.ControlFrame.TopLeftControl.Visible = false
end
@@ -0,0 +1,109 @@
local controlFrame = script.Parent:FindFirstChild("ControlFrame")
if not controlFrame then return end
local topLeftControl = controlFrame:FindFirstChild("TopLeftControl")
local bottomLeftControl = controlFrame:FindFirstChild("BottomLeftControl")
local bottomRightControl = controlFrame:FindFirstChild("BottomRightControl")
local frameTip = Instance.new("TextLabel")
frameTip.Name = "ToolTip"
frameTip.Text = ""
frameTip.Font = Enum.Font.ArialBold
frameTip.FontSize = Enum.FontSize.Size12
frameTip.TextColor3 = Color3.new(1,1,1)
frameTip.BorderSizePixel = 0
frameTip.ZIndex = 10
frameTip.Size = UDim2.new(2,0,1,0)
frameTip.Position = UDim2.new(1,0,0,0)
frameTip.BackgroundColor3 = Color3.new(0,0,0)
frameTip.BackgroundTransparency = 1
frameTip.TextTransparency = 1
frameTip.TextWrap = true
local inside = Instance.new("BoolValue")
inside.Name = "inside"
inside.Value = false
inside.Parent = frameTip
function setUpListeners(frameToListen)
local fadeSpeed = 0.1
frameToListen.Parent.MouseEnter:connect(function()
if frameToListen:FindFirstChild("inside") then
frameToListen.inside.Value = true
wait(1.2)
if frameToListen.inside.Value then
while frameToListen.inside.Value and frameToListen.BackgroundTransparency > 0 do
frameToListen.BackgroundTransparency = frameToListen.BackgroundTransparency - fadeSpeed
frameToListen.TextTransparency = frameToListen.TextTransparency - fadeSpeed
wait()
end
end
end
end)
function killTip(killFrame)
killFrame.inside.Value = false
killFrame.BackgroundTransparency = 1
killFrame.TextTransparency = 1
end
frameToListen.Parent.MouseLeave:connect(function() killTip(frameToListen) end)
frameToListen.Parent.MouseButton1Click:connect(function() killTip(frameToListen) end)
end
function createSettingsButtonTip(parent)
if parent == nil then
parent = bottomLeftControl:FindFirstChild("SettingsButton")
end
local toolTip = frameTip:clone()
toolTip.RobloxLocked = true
toolTip.Text = "Settings/Leave Game"
toolTip.Position = UDim2.new(0,0,0,-18)
toolTip.Size = UDim2.new(0,120,0,20)
toolTip.Parent = parent
setUpListeners(toolTip)
end
wait(5) -- make sure we are loaded in, won't need tool tips for first 5 seconds anyway
---------------- set up Bottom Left Tool Tips -------------------------
local bottomLeftChildren = bottomLeftControl:GetChildren()
local hasSettingsTip = false
for i = 1, #bottomLeftChildren do
if bottomLeftChildren[i].Name == "Exit" then
local exitTip = frameTip:clone()
exitTip.RobloxLocked = true
exitTip.Text = "Leave Place"
exitTip.Position = UDim2.new(0,0,-1,0)
exitTip.Size = UDim2.new(1,0,1,0)
exitTip.Parent = bottomLeftChildren[i]
setUpListeners(exitTip)
elseif bottomLeftChildren[i].Name == "SettingsButton" then
hasSettingsTip = true
createSettingsButtonTip(bottomLeftChildren[i])
end
end
---------------- set up Bottom Right Tool Tips -------------------------
local bottomRightChildren = bottomRightControl:GetChildren()
for i = 1, #bottomRightChildren do
if bottomRightChildren[i].Name:find("Camera") ~= nil then
local cameraTip = frameTip:clone()
cameraTip.RobloxLocked = true
cameraTip.Text = "Camera View"
if bottomRightChildren[i].Name:find("Zoom") then
cameraTip.Position = UDim2.new(-1,0,-1.5)
else
cameraTip.Position = UDim2.new(0,0,-1.5,0)
end
cameraTip.Size = UDim2.new(2,0,1.25,0)
cameraTip.Parent = bottomRightChildren[i]
setUpListeners(cameraTip)
end
end