Copy salient and essential scripts and models from Plane Building Roblox
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
local defaultPosition = script.Parent.Saves.Position
|
||||
local defaultSize = script.Parent.Saves.Size
|
||||
local expandedPosition = UDim2.new(0.5,-defaultSize.X.Offset,0,defaultPosition.Y.Offset)
|
||||
local expandedSize = UDim2.new(0,defaultSize.X.Offset*2,0,defaultSize.Y.Offset)
|
||||
local toggle = false
|
||||
local input = game:GetService("UserInputService")
|
||||
local function expansion()
|
||||
toggle = not toggle
|
||||
local newSize = defaultSize
|
||||
local newPosition = defaultPosition
|
||||
if toggle then
|
||||
newSize = expandedSize
|
||||
newPosition = expandedPosition
|
||||
end
|
||||
script.Parent.Saves:TweenSizeAndPosition(newSize,newPosition,Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.5,true)
|
||||
end
|
||||
input.InputEnded:Connect(function(input,irrelevant)
|
||||
if not irrelevant and script.Parent.Enabled then
|
||||
if input.UserInputType == Enum.UserInputType.Keyboard then
|
||||
if input.KeyCode == Enum.KeyCode.E then
|
||||
expansion()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
script.Parent.MinimizeButton.Activated:Connect(expansion)
|
||||
@@ -0,0 +1,43 @@
|
||||
local template = script.Notification
|
||||
local function Popup(title,message)
|
||||
local notification = template:Clone()
|
||||
notification.TitleLabel.Text = title
|
||||
notification.ContentLabel.Text = message
|
||||
notification.Parent = script.Parent.Parent.ScreenGui
|
||||
notification.Position = UDim2.new(0.5,0,0.5,0)
|
||||
notification.Size = UDim2.new(0,400,0,0)
|
||||
notification.AnchorPoint = Vector2.one*0.5
|
||||
notification.UIDragDetector.Enabled = true
|
||||
notification.TitleLabel.DestroyButton.Activated:Connect(function()
|
||||
notification:Destroy()
|
||||
end)
|
||||
end
|
||||
local function Notification(title,message)
|
||||
local notification = template:Clone()
|
||||
notification.TitleLabel.Text = title or "Untitled"
|
||||
notification.ContentLabel.Text = tostring(message)
|
||||
notification.Parent = script.Parent.Left
|
||||
notification.Size = UDim2.new(0,0,0,0)
|
||||
notification.TitleLabel.DestroyButton.Visible = false
|
||||
local tapped = function()
|
||||
Popup(title,message)
|
||||
end
|
||||
notification.TouchTap:Connect(tapped)
|
||||
notification.InputEnded:Connect(function(input)
|
||||
if input.UserInputType == Enum.UserInputType.MouseButton1 then tapped() end
|
||||
end)
|
||||
notification:TweenSize(UDim2.new(0,210,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.5,true,function()
|
||||
wait(3)
|
||||
notification.ContentLabel.Size = UDim2.new(0,notification.ContentLabel.AbsoluteSize.X,0,notification.ContentLabel.AbsoluteSize.Y)
|
||||
notification:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.5,true,function()
|
||||
notification:Destroy()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
require(game.ReplicatedFirst.ReadyModule)
|
||||
_G.Remotes.Notification.OnClientEvent:Connect(function(title,message)
|
||||
Notification(title,message)
|
||||
end)
|
||||
_G.Events.Notification.Event:Connect(function(title,message)
|
||||
Notification(title,message)
|
||||
end)
|
||||
@@ -0,0 +1,159 @@
|
||||
require(game.ReplicatedFirst.ReadyModule)
|
||||
local optionFrame = script.Parent:WaitForChild("OptionFrame")
|
||||
local options = optionFrame:WaitForChild("Options")
|
||||
function registerToggle(name,callback)
|
||||
local button = options:WaitForChild(name)
|
||||
local value = button.TextButton.Text == "On"
|
||||
button.TextButton.MouseButton1Click:Connect(function()
|
||||
value = not value
|
||||
local new = "On"
|
||||
if not value then
|
||||
new = "Off"
|
||||
end
|
||||
button.TextButton.Text = new
|
||||
callback(value)
|
||||
_G.Events.Notification:Fire(name,new)
|
||||
end)
|
||||
end
|
||||
local function registerSlider(name,callback)
|
||||
local slider = options:WaitForChild(name)
|
||||
local drag = slider:WaitForChild("Slider"):WaitForChild("Drag")
|
||||
local etch = slider:WaitForChild("Slider"):WaitForChild("Etch")
|
||||
local hold
|
||||
local position
|
||||
local event
|
||||
local function changed(object)
|
||||
if hold then
|
||||
local delta = (object.Position - hold).X
|
||||
local final = math.clamp((delta/(etch.AbsoluteSize.X))+position,0,1)
|
||||
drag.Position = UDim2.new(final,0,0,0)
|
||||
callback(final)
|
||||
else
|
||||
event:Disconnect()
|
||||
end
|
||||
end
|
||||
drag.InputBegan:Connect(function(object)
|
||||
if object.UserInputType == Enum.UserInputType.MouseButton1 or object.UserInputType == Enum.UserInputType.Touch then
|
||||
hold = object.Position
|
||||
position = drag.Position.X.Scale
|
||||
event = _G.Input.InputChanged:Connect(changed)
|
||||
end
|
||||
end)
|
||||
drag.InputEnded:Connect(function(object)
|
||||
if object.UserInputType == Enum.UserInputType.MouseButton1 or object.UserInputType == Enum.UserInputType.Touch then
|
||||
hold = nil
|
||||
position = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
local collaborateButton = options:WaitForChild("CollaborateButton")
|
||||
collaborateButton.MouseButton1Click:Connect(function()
|
||||
_G.Remotes.Collaborate:InvokeServer(nil,nil)
|
||||
end)
|
||||
registerSlider("Air",function(value)
|
||||
game.Workspace.CompensateDensity.Value = value * 2
|
||||
end)
|
||||
registerToggle("Destruction",function(value)
|
||||
game.Workspace.Destruction.Value = value
|
||||
end)
|
||||
registerToggle("Combat",function(value)
|
||||
game.Workspace.Combat.Value = value
|
||||
if value then
|
||||
_G.Remotes.Combat:InvokeServer()
|
||||
end
|
||||
end)
|
||||
registerToggle("Debug",function(value)
|
||||
game.Workspace.DebugWings.Value = value
|
||||
end)
|
||||
registerToggle("Stats",function(value)
|
||||
_G.StatisticsFrame.Visible = value
|
||||
end)
|
||||
registerSlider("Dead",function(value)
|
||||
local val = value > 0.5
|
||||
game.Lighting.ColorCorrection.Enabled = val
|
||||
game.Lighting.ColorGrading.Enabled = val
|
||||
end)
|
||||
local defaultDensity = 0.262
|
||||
local defaultBlur = 24
|
||||
local changeFog = function(value)
|
||||
game.Lighting.Atmosphere.Density = defaultDensity*value
|
||||
game.Lighting.Blur.Size = defaultBlur*value
|
||||
end
|
||||
local changeTime = function(value)
|
||||
game.Lighting.Time.Value = value * 24
|
||||
end
|
||||
registerSlider("Fog",changeFog)
|
||||
registerSlider("Time",changeTime)
|
||||
--if _G.Statistics.fog_enabled then changeFog() options:WaitForChild("Fog").Text = "Off" end
|
||||
local minimized = true
|
||||
local toggle = _G:WaitFor("OptionsButton")
|
||||
local extended = optionFrame.Position
|
||||
local retracted = UDim2.new(UDim.new(0,-optionFrame.AbsoluteSize.X),extended.Y)
|
||||
optionFrame.Position = retracted
|
||||
optionFrame.Visible = true
|
||||
local function toggleMenu()
|
||||
print("toggle")
|
||||
minimized = not minimized
|
||||
optionFrame.Visible = not minimized
|
||||
--[[local new
|
||||
if minimized then
|
||||
new = retracted
|
||||
else
|
||||
new = extended
|
||||
end
|
||||
optionFrame:TweenPosition(new,Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.4,true)]]
|
||||
end
|
||||
toggle.Activated:Connect(toggleMenu)
|
||||
local input = game:GetService("UserInputService")
|
||||
input.InputBegan:Connect(function(input,irrelevant)
|
||||
if not irrelevant and input.KeyCode == Enum.KeyCode.Backquote then
|
||||
if input:IsModifierKeyDown(Enum.ModifierKey.Shift) then
|
||||
minimized = true
|
||||
optionFrame.Visible = false
|
||||
optionFrame.Options.Command.CommandBox:ReleaseFocus()
|
||||
else
|
||||
minimized = false
|
||||
optionFrame.Visible = true
|
||||
wait() optionFrame.Options.Command.CommandBox:CaptureFocus()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,false)
|
||||
local messageFrame = script.Parent:WaitForChild("MessageFrame")
|
||||
local messageBox = messageFrame:WaitForChild("TextBox")
|
||||
local messageContainer = messageFrame:WaitForChild("ScrollingFrame")
|
||||
_G.Remotes.Chat.OnClientEvent:Connect(function(title,content,color)
|
||||
local message = messageContainer.Template.Message:Clone()
|
||||
message.Parent = messageContainer
|
||||
message.Title.Text = title
|
||||
message.Content.Text = content
|
||||
message.Title.TextColor3 = color
|
||||
message.Visible = true
|
||||
messageContainer.CanvasPosition = Vector2.new(0, messageContainer.CanvasSize.Y.Offset - messageContainer.AbsoluteSize.Y)
|
||||
end)
|
||||
_G.Input.InputBegan:Connect(function(input,irrelevant)
|
||||
if not irrelevant and input.KeyCode == Enum.KeyCode.Slash then
|
||||
messageBox:CaptureFocus()
|
||||
end
|
||||
end)
|
||||
_G:WaitFor("ChatHideButton").Activated:Connect(function()
|
||||
messageFrame.Visible = not messageFrame.Visible
|
||||
end)
|
||||
messageBox.FocusLost:Connect(function(enterPressed)
|
||||
if enterPressed then
|
||||
local message = messageBox.Text
|
||||
:gsub("\n","<br/>")
|
||||
:gsub("<br>","<br/>")
|
||||
:gsub("<big>(.-)</big>","<font size=\"28\">%1</font>")
|
||||
:gsub("<small>(.-)</small>","<font size=\"10\">%1</font>")
|
||||
:gsub("<green>(.-)</green>","<font color=\"#00FF00\">%1</font>")
|
||||
:gsub("<red>(.-)</red>","<font color=\"#FF0000\">%1</font>")
|
||||
:gsub("<trans.->(.-)</trans.->","<font transparency=\"0.5\">%1</font>")
|
||||
:gsub("_(.-)_","<i>%1</i>")
|
||||
:gsub("*(.-)*","<b>%1</b>")
|
||||
if #message == 0 then return end
|
||||
_G.Remotes.Chat:FireServer(message)
|
||||
messageBox.Text = ""
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,2 @@
|
||||
require(game.ReplicatedFirst.ReadyModule)
|
||||
require(_G.Modules.PlacementModule).init(script.Parent)
|
||||
@@ -0,0 +1,2 @@
|
||||
require(game.ReplicatedFirst.ReadyModule)
|
||||
require(_G.Modules.SaveModule).InitUI(script)
|
||||
@@ -0,0 +1,183 @@
|
||||
require(game.ReplicatedFirst.ReadyModule)
|
||||
local shopGui = script.Parent
|
||||
_G.ShopGui = shopGui
|
||||
local shopFrame = shopGui.Items
|
||||
local shopMaterial = shopGui.CashLabel
|
||||
local shopBackButton = shopGui.BackButton
|
||||
local shopSearch = shopGui.Search
|
||||
|
||||
-- Parts
|
||||
local partsStore = _G.Storage:WaitForChild("Parts")
|
||||
local namedFrames = {}
|
||||
local directNamedFrames = {}
|
||||
local folders = {}
|
||||
local currentFolder = partsStore
|
||||
local currentTerm = ""
|
||||
|
||||
local function createItemFrame(item)
|
||||
local defaultFrame = shopFrame.Grid.ItemFrame
|
||||
defaultFrame.Visible = false
|
||||
|
||||
-- Create ViewportFrame and put a camera in
|
||||
local itemFrame = defaultFrame:Clone()
|
||||
itemFrame.Parent = shopFrame
|
||||
itemFrame.ItemLabel.Text = item:GetAttribute("Name") or item.Name
|
||||
itemFrame.Visible = true
|
||||
if not item:HasTag("ConnectorObject") then itemFrame.PolyLabel:Destroy() end
|
||||
itemFrame.NewLabel:Destroy()
|
||||
itemFrame.Name = item:GetAttribute("Name") or item.Name
|
||||
|
||||
local viewportFrame = itemFrame.ViewportFrame
|
||||
|
||||
local camera = Instance.new("Camera")
|
||||
camera.Parent = viewportFrame
|
||||
|
||||
viewportFrame.CurrentCamera = camera
|
||||
|
||||
item = item:Clone()
|
||||
item.Parent = viewportFrame
|
||||
item:PivotTo(item:GetAttribute("Rotation") or CFrame.identity)
|
||||
local distance
|
||||
local cameraRotation = 45
|
||||
if item:IsA("BasePart") then
|
||||
distance = item.Size.Magnitude
|
||||
elseif item:IsA("Model") then
|
||||
if not item.PrimaryPart then
|
||||
warn(item:GetFullName().." has no PrimaryPart, please set one!")
|
||||
item.PrimaryPart = item:FindFirstChildWhichIsA("BasePart")
|
||||
end
|
||||
distance = item:GetExtentsSize().Magnitude
|
||||
end
|
||||
|
||||
local function rotateCamera()
|
||||
camera.CFrame = CFrame.fromEulerAnglesYXZ(-0.8,math.rad(cameraRotation),0)
|
||||
camera.CFrame = camera.CFrame + camera.CFrame.LookVector * -(distance/1.2)
|
||||
end
|
||||
rotateCamera()
|
||||
|
||||
local mouseInside = false
|
||||
viewportFrame.MouseEnter:Connect(function()
|
||||
mouseInside = true
|
||||
viewportFrame.BackgroundColor3 = Color3.new(0.75,0.75,0.75)
|
||||
while wait() and mouseInside do
|
||||
cameraRotation = cameraRotation + 0.33
|
||||
rotateCamera()
|
||||
end
|
||||
end)
|
||||
viewportFrame.MouseLeave:Connect(function() mouseInside = false viewportFrame.BackgroundColor3 = Color3.new(1,1,1) end)
|
||||
|
||||
return itemFrame
|
||||
end
|
||||
|
||||
local function clearItems()
|
||||
for _,item in pairs(shopFrame:GetChildren()) do
|
||||
if item:IsA("Frame") then
|
||||
item.Parent = nil -- Now is this a good idea or not...
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local f = string.find
|
||||
local l = string.lower
|
||||
local function loadSearch(term)
|
||||
clearItems()
|
||||
wait()
|
||||
term = l(term)
|
||||
for _,info in pairs(namedFrames) do
|
||||
if f(l(info[1]),term,1,true) then -- A crude search if anything
|
||||
info[2].Parent = shopFrame
|
||||
end
|
||||
end
|
||||
for _,info in pairs(directNamedFrames) do
|
||||
if f(l(info[1]),term,1,true) then -- A crude search if anything
|
||||
info[2].Parent = shopFrame
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shopSearch.FocusLost:Connect(function(enter, inputObject)
|
||||
if enter then
|
||||
-- add a quick enter
|
||||
end
|
||||
end)
|
||||
|
||||
local function loadFolder(folder)
|
||||
currentFolder = folder
|
||||
clearItems()
|
||||
wait()
|
||||
for _,frame in pairs(folders[folder]) do
|
||||
frame.Parent = shopFrame
|
||||
end
|
||||
end
|
||||
|
||||
shopSearch.Changed:Connect(function()
|
||||
if currentTerm == shopSearch.Text then return end
|
||||
currentTerm = shopSearch.Text
|
||||
if #shopSearch.Text > 0 then
|
||||
loadSearch(shopSearch.Text)
|
||||
else
|
||||
loadFolder(currentFolder)
|
||||
end
|
||||
end)
|
||||
|
||||
local existing = {}
|
||||
local t = 200
|
||||
local function registerItem(item)
|
||||
if existing[item] then return end
|
||||
existing[item] = true
|
||||
if item:HasTag("DoNotPlace") then return end
|
||||
local isFolder = item:IsA("Folder")
|
||||
local isPart = item.Parent:IsA("Folder") and (item:IsA("Model") or item:IsA("BasePart"))
|
||||
if isFolder or isPart then
|
||||
local model = item
|
||||
if isFolder then
|
||||
local smallestOrder = t+1
|
||||
local smallestItem
|
||||
for _,child in pairs(item:GetDescendants()) do
|
||||
if not (child.Parent:IsA("Folder") and (child:IsA("BasePart") or child:IsA("Model"))) then continue end
|
||||
local order = child:GetAttribute("Order") or t
|
||||
if order < smallestOrder then smallestOrder = order smallestItem = child end
|
||||
end
|
||||
model = smallestItem
|
||||
end
|
||||
if not model then warn(item:GetFullName().." has no children.") return end
|
||||
local frame = createItemFrame(model)
|
||||
frame.LayoutOrder = item:GetAttribute("Order") or t
|
||||
folders[item.Parent] = folders[item.Parent] or {} -- Make sure the folder exists
|
||||
table.insert(folders[item.Parent],frame)
|
||||
if isPart then
|
||||
if item:GetAttribute("Name") then table.insert(namedFrames,{item:GetAttribute("Name"),frame}) end
|
||||
table.insert(directNamedFrames,{item.Name,frame})
|
||||
frame.InputEnded:Connect(function(inputObject)
|
||||
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 or inputObject.UserInputType == Enum.UserInputType.Touch then
|
||||
_G.Events.Pick:Fire(item)
|
||||
if item.Parent:IsA("Folder") and item.Parent:HasTag("AutoBack") then
|
||||
loadFolder(item.Parent.Parent)
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
frame.ItemLabel.Text = item.Name
|
||||
frame.InputEnded:Connect(function(inputObject)
|
||||
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 or inputObject.UserInputType == Enum.UserInputType.Touch then
|
||||
loadFolder(item)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function loadStore()
|
||||
for _,item in pairs(partsStore:GetDescendants()) do
|
||||
registerItem(item)
|
||||
end
|
||||
loadFolder(currentFolder)
|
||||
end
|
||||
|
||||
shopBackButton.MouseButton1Click:Connect(function()
|
||||
local parent = currentFolder.Parent
|
||||
if currentFolder == partsStore then parent = partsStore end
|
||||
loadFolder(parent)
|
||||
end)
|
||||
|
||||
loadStore()
|
||||
@@ -0,0 +1,182 @@
|
||||
local StarterGui = game:GetService("StarterGui")
|
||||
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
|
||||
|
||||
local frame = script.Parent
|
||||
frame.Visible = true
|
||||
|
||||
local input = game:GetService("UserInputService")
|
||||
|
||||
local player = game.Players.LocalPlayer
|
||||
local backpack = player.Backpack
|
||||
|
||||
local stroke = script:WaitForChild("UIStroke")
|
||||
|
||||
local currentTool = nil
|
||||
|
||||
local tools = {}
|
||||
|
||||
local frames = {}
|
||||
|
||||
local function isToolRegistered(tool) return tools[tool] end
|
||||
|
||||
local function getToolFrame(tool) return frames[tool] end
|
||||
|
||||
local function stockTool(tool)
|
||||
tool.Parent = backpack
|
||||
stroke.Parent = script
|
||||
stroke.Transparency = 1
|
||||
frames[tool].Deselected:Fire()
|
||||
end
|
||||
|
||||
local index = 0
|
||||
|
||||
local function setTool(tool)
|
||||
if currentTool then stockTool(currentTool) end -- If there is already a tool equipped, dequip it
|
||||
if currentTool == tool then currentTool = nil return end -- If this tool is already equipped, remove it and stop
|
||||
|
||||
if tonumber(tool.Name) then index = tonumber(tool.Name) end
|
||||
frames[tool].Selected:Fire()
|
||||
tool.Parent = player.Character -- Equip the new tool
|
||||
stroke.Parent = frames[tool]
|
||||
stroke.Transparency = 0.2
|
||||
currentTool = tool
|
||||
end
|
||||
|
||||
local nameToInteger = {
|
||||
["One"] = 1,
|
||||
["Two"] = 2,
|
||||
["Three"] = 3,
|
||||
["Four"] = 4,
|
||||
["Five"] = 5,
|
||||
["Six"] = 6,
|
||||
["Seven"] = 7,
|
||||
["Eight"] = 8,
|
||||
["Nine"] = 9
|
||||
}
|
||||
|
||||
input.InputBegan:Connect(function(input,irrelevant)
|
||||
if not irrelevant then
|
||||
local tools = 0
|
||||
for _,item in pairs(frame.ScrollingFrame:GetChildren()) do
|
||||
if item:FindFirstChild("ToolReference") then tools = tools + 1 end
|
||||
end
|
||||
local inputted = false
|
||||
if input.UserInputType == Enum.UserInputType.Keyboard then
|
||||
local number = nameToInteger[input.KeyCode.Name]
|
||||
if number then inputted = true index = number end
|
||||
elseif input.KeyCode == Enum.KeyCode.ButtonR1 then
|
||||
inputted = true
|
||||
index = index + 1
|
||||
elseif input.KeyCode == Enum.KeyCode.ButtonL1 then
|
||||
inputted = true
|
||||
index = index - 1
|
||||
end
|
||||
index = math.clamp(index,0,tools+1)
|
||||
if not inputted then return end
|
||||
local toolFrame = frame.ScrollingFrame:FindFirstChild(tostring(index))
|
||||
if toolFrame then
|
||||
setTool(toolFrame.ToolReference.Value)
|
||||
else
|
||||
if currentTool then stockTool(currentTool) currentTool = nil end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function createToolFrame(tool)
|
||||
local toolFrame = frame.ScrollingFrame.Template.Tool:Clone()
|
||||
toolFrame.ToolReference.Value = tool
|
||||
local layout = tool:WaitForChild("LayoutOrderValue",1)
|
||||
if layout then layout = layout.Value
|
||||
else layout = #frames end
|
||||
toolFrame.LayoutOrder = layout
|
||||
frames[tool] = toolFrame
|
||||
tools[tool] = tool
|
||||
local clone = tool:Clone()
|
||||
for _,child in pairs(clone:GetChildren()) do
|
||||
if child:IsA("Script") then
|
||||
child:Destroy()
|
||||
end
|
||||
end
|
||||
toolFrame.Parent = frame.ScrollingFrame
|
||||
toolFrame.Visible = true
|
||||
toolFrame.Name = tostring(toolFrame.LayoutOrder)
|
||||
local viewport = toolFrame.ViewportFrame
|
||||
viewport.Name = clone.Name
|
||||
clone.Parent = viewport
|
||||
local camera = Instance.new("Camera")
|
||||
viewport.CurrentCamera = camera
|
||||
camera.Parent = viewport
|
||||
local label = toolFrame.TextLabel
|
||||
label.Text = tool.Name
|
||||
local cframe,size = clone:GetBoundingBox()
|
||||
|
||||
local cameraRotation = 45
|
||||
local distance = size.Magnitude
|
||||
|
||||
local function rotateCamera() -- To constantly spin the tool view
|
||||
camera.CFrame = CFrame.new(cframe.Position) * CFrame.fromEulerAnglesYXZ(-0.3,math.rad(cameraRotation),0)
|
||||
camera.CFrame = camera.CFrame + camera.CFrame.LookVector * -(distance/1.2)
|
||||
end
|
||||
|
||||
rotateCamera() -- To initialise the camera CFrame once
|
||||
|
||||
local mouseInside = 0 -- Rotate camera while the mouse is inside the tool
|
||||
local mouseEnter = function(no_back)
|
||||
mouseInside = mouseInside + 1
|
||||
if not no_back then toolFrame.BackgroundColor3 = Color3.new(0.75,0.75,0.75) end
|
||||
if mouseInside == 1 then while wait() and mouseInside > 0 do
|
||||
cameraRotation = cameraRotation + 1.5 * mouseInside
|
||||
rotateCamera()
|
||||
end end
|
||||
end
|
||||
local mouseLeave = function(no_back)
|
||||
mouseInside = mouseInside - 1
|
||||
if not no_back then toolFrame.BackgroundColor3 = Color3.new(1,1,1) end
|
||||
end
|
||||
viewport.MouseEnter:Connect(mouseEnter)
|
||||
viewport.MouseLeave:Connect(mouseLeave)
|
||||
toolFrame.Selected.Event:Connect(mouseEnter)
|
||||
toolFrame.Deselected.Event:Connect(mouseLeave)
|
||||
return toolFrame
|
||||
end
|
||||
|
||||
local function unregisterTool(tool)
|
||||
--print(tool:GetFullName())
|
||||
if currentTool == tool then stroke.Parent = script currentTool = nil end
|
||||
if frames[tool] then frames[tool]:Destroy() end
|
||||
frames[tool] = nil
|
||||
tools[tool] = nil
|
||||
end
|
||||
|
||||
local function registerTool(tool)
|
||||
if isToolRegistered(tool) then return end -- Don't register an existing tool
|
||||
|
||||
tool.AncestryChanged:Connect(function(tool,parent) -- Event for when parent changes
|
||||
if not (parent == player.Character or parent == backpack) then -- If the tool is not a parent of the character or backpack, it is dropped
|
||||
unregisterTool(tool)
|
||||
end
|
||||
end)
|
||||
|
||||
createToolFrame(tool)
|
||||
|
||||
-- todo: save me
|
||||
frames[tool].InputEnded:Connect(function(inputObject) -- When the mouse button or touch is clicked (XBOX + VR CONTROL NEEDED)
|
||||
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 or inputObject.UserInputType == Enum.UserInputType.Touch then
|
||||
setTool(tool)
|
||||
end
|
||||
end)
|
||||
--[[frames[tool].TouchTap:Connect(function()
|
||||
setTool(tool)
|
||||
end)]]
|
||||
end
|
||||
|
||||
game.Players.LocalPlayer.ChildAdded:Connect(function(child)
|
||||
if currentTool then unregisterTool(currentTool) end
|
||||
if child:IsA("Backpack") then backpack = child end
|
||||
backpack.ChildAdded:Connect(registerTool)
|
||||
backpack.ChildRemoved:Connect(registerTool)
|
||||
end)
|
||||
|
||||
for _,tool in pairs(backpack:GetChildren()) do
|
||||
registerTool(tool)
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
Most things are not relative to the original hierarchy. I'm just dumping everything here.
|
||||
Reference in New Issue
Block a user