I tried making an open/close script for my GUI, but I just can't get my head around it.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local pump = game.ServerStorage.Part local pump1 = game.Workspace.Part1 local isButtonDown = false local Clonedpump local selectionBox = Instance.new("SelectionBox") local enabled = false script.Parent.MouseButton1Down:connect(function() if enabled == false then enabled = true else enabled = false end if enabled == true then mouse.Button1Down:connect(function() isButtonDown = true pump1.Parent = game.ServerStorage Clonedpump = pump:Clone() Clonedpump.Parent = game.Workspace mouse.TargetFilter = pump mouse.TargetFilter = Clonedpump Clonedpump.Position = mouse.Hit.p isButtonDown = false enabled = false end) repeat pump1.Parent = game.Workspace mouse.TargetFilter = pump1 selectionBox.Adornee = pump1 selectionBox.Color3 = Color3.new(0,255,0) selectionBox.Parent = pump1 pump1.Position = mouse.Hit.p wait() until isButtonDown == true end end)
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local pump = game.ServerStorage.Part --The client cannot access ServerStorage, use ReplicatedStorage local pump1 = game.Workspace.Part1 local isButtonDown = false local Clonedpump local selectionBox = Instance.new("SelectionBox") local enabled = false script.Parent.MouseButton1Down:connect(function() if not enabled then enabled = true wait() pump1.Parent = game.Workspace mouse.TargetFilter = pump1 selectionBox.Adornee = pump1 selectionBox.Color3 = Color3.new(0,255,0) selectionBox.Parent = pump1 repeat pump1.Position = mouse.Hit.p wait() until not enabled end else enabled = false pump1.Parent = game.ServerStorage -- again, needs to be changed end end) mouse.Button1Down:connect(function() if enabled then -- isButtonDown = true --redundant Clonedpump = pump:Clone() mouse.TargetFilter = pump mouse.TargetFilter = Clonedpump Clonedpump.Position = mouse.Hit.p Clonedpump.Parent = Workspace --It's best to set the parent last -- isButtonDown = false --redundant end end)
Honestly, no idea if that will even work. You will still need to fix the couple things I marked.