SHARE
TWEET

Untitled

a guest Nov 12th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,game,owner = owner,game
  3. local RealPlayer = Player
  4. do
  5.     print("FE Compatibility code by Mokiros | Showcase by Bacon Hair!")
  6.     local rp = RealPlayer
  7.     script.Parent = rp.Character
  8.    
  9.     --RemoteEvent for communicating
  10.     local Event = Instance.new("RemoteEvent")
  11.     Event.Name = "UserInput_Event"
  12.  
  13.     --Fake event to make stuff like Mouse.KeyDown work
  14.     local function fakeEvent()
  15.         local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  16.         t.connect = t.Connect
  17.         return t
  18.     end
  19.  
  20.     --Creating fake input objects with fake variables
  21.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  22.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  23.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  24.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  25.     end}
  26.     --Merged 2 functions into one by checking amount of arguments
  27.     CAS.UnbindAction = CAS.BindAction
  28.  
  29.     --This function will trigger the events that have been :Connect()'ed
  30.     local function te(self,ev,...)
  31.         local t = m[ev]
  32.         if t and t._fakeEvent then
  33.             for _,f in pairs(t.Functions) do
  34.                 f(...)
  35.             end
  36.         end
  37.     end
  38.     m.TrigEvent = te
  39.     UIS.TrigEvent = te
  40.  
  41.     Event.OnServerEvent:Connect(function(plr,io)
  42.         if plr~=rp then return end
  43.         m.Target = io.Target
  44.         m.Hit = io.Hit
  45.         if not io.isMouse then
  46.             local b = io.UserInputState == Enum.UserInputState.Begin
  47.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49.             end
  50.             for _,t in pairs(CAS.Actions) do
  51.                 for _,k in pairs(t.Keys) do
  52.                     if k==io.KeyCode then
  53.                         t.Function(t.Name,io.UserInputState,io)
  54.                     end
  55.                 end
  56.             end
  57.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  58.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  59.         end
  60.     end)
  61.     Event.Parent = NLS([==[
  62.     local Player = game:GetService("Players").LocalPlayer
  63.     local Event = script:WaitForChild("UserInput_Event")
  64.  
  65.     local Mouse = Player:GetMouse()
  66.     local UIS = game:GetService("UserInputService")
  67.     local input = function(io,a)
  68.         if a then return end
  69.         --Since InputObject is a client-side instance, we create and pass table instead
  70.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  71.     end
  72.     UIS.InputBegan:Connect(input)
  73.     UIS.InputEnded:Connect(input)
  74.  
  75.     local h,t
  76.     --Give the server mouse data 30 times every second, but only if the values changed
  77.     --If player is not moving their mouse, client won't fire events
  78.     while wait(1/30) do
  79.         if h~=Mouse.Hit or t~=Mouse.Target then
  80.             h,t=Mouse.Hit,Mouse.Target
  81.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  82.         end
  83.     end]==],Player.Character)
  84.  
  85.     ----Sandboxed game object that allows the usage of client-side methods and services
  86.     --Real game object
  87.     local _rg = game
  88.  
  89.     --Metatable for fake service
  90.     local fsmt = {
  91.         __index = function(self,k)
  92.             local s = rawget(self,"_RealService")
  93.             if s then return s[k] end
  94.         end,
  95.         __newindex = function(self,k,v)
  96.             local s = rawget(self,"_RealService")
  97.             if s then s[k]=v end
  98.         end,
  99.         __call = function(self,...)
  100.             local s = rawget(self,"_RealService")
  101.             if s then return s(...) end
  102.         end
  103.     }
  104.     local function FakeService(t,RealService)
  105.         t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  106.         return setmetatable(t,fsmt)
  107.     end
  108.  
  109.     --Fake game object
  110.     local g = {
  111.         GetService = function(self,s)
  112.             return self[s]
  113.         end,
  114.         Players = FakeService({
  115.             LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  116.         },"Players"),
  117.         UserInputService = FakeService(UIS,"UserInputService"),
  118.         ContextActionService = FakeService(CAS,"ContextActionService"),
  119.     }
  120.     rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  121.     g.service = g.GetService
  122.    
  123.     g.RunService = FakeService({
  124.         RenderStepped = _rg:GetService("RunService").Heartbeat,
  125.         BindToRenderStep = function(self,name,_,fun)
  126.  
  127.         end,
  128.         UnbindFromRenderStep = function(self,name)
  129.             self._btrs[name]:Disconnect()
  130.         end,
  131.     },"RunService")
  132.  
  133.     setmetatable(g,{
  134.         __index=function(self,s)
  135.             return _rg:GetService(s) or typeof(_rg[s])=="function"
  136.             and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  137.         end,
  138.         __newindex = fsmt.__newindex,
  139.         __call = fsmt.__call
  140.     })
  141.     --Changing owner to fake player object to support owner:GetMouse()
  142.     game,owner = g,g.Players.LocalPlayer
  143. end
  144.  
  145. function sandbox(var,func)
  146.     local env = getfenv(func)
  147.     local newenv = setmetatable({},{
  148.         __index = function(self,k)
  149.             if k=="script" then
  150.                 return var
  151.             else
  152.                 return env[k]
  153.             end
  154.         end,
  155.     })
  156.     setfenv(func,newenv)
  157.     return func
  158. end
  159. cors = {}
  160. mas = Instance.new("Model",game:GetService("Lighting"))
  161. Tool0 = Instance.new("Tool")
  162. Part1 = Instance.new("Part")
  163. WeldConstraint2 = Instance.new("WeldConstraint")
  164. LocalScript3 = Instance.new("LocalScript")
  165. Sound4 = Instance.new("Sound")
  166. Part5 = Instance.new("Part")
  167. WeldConstraint6 = Instance.new("WeldConstraint")
  168. Part7 = Instance.new("Part")
  169. SpecialMesh8 = Instance.new("SpecialMesh")
  170. Script9 = Instance.new("Script")
  171. Tool0.Name = "Pistol"
  172. Tool0.Parent = mas
  173. Tool0.Grip = CFrame.new(0, -0, 0, -0.0777099356, 0, -0.996976018, 0, 1, 0, 0.996976018, 0, -0.0777099356)
  174. Tool0.GripForward = Vector3.new(0.996976018, -0, 0.0777099356)
  175. Tool0.GripRight = Vector3.new(-0.0777099356, 0, 0.996976018)
  176. Part1.Name = "Handle"
  177. Part1.Parent = Tool0
  178. Part1.CFrame = CFrame.new(54.8407516, 0.696877956, -7.14729881, -0.000168002356, -0.0115140071, 0.999939024, -0.000129001855, 0.999939024, 0.0115140686, -1, -0.000127059597, -0.00016947712)
  179. Part1.Orientation = Vector3.new(-0.660000026, 90.0100021, -0.00999999978)
  180. Part1.Position = Vector3.new(54.8407516, 0.696877956, -7.14729881)
  181. Part1.Rotation = Vector3.new(-90.8399963, 89.3700027, 90.8399963)
  182. Part1.Color = Color3.new(0.0666667, 0.0666667, 0.0666667)
  183. Part1.Transparency = 1
  184. Part1.Size = Vector3.new(0.5, 0.989999652, 0.341440022)
  185. Part1.BackSurface = Enum.SurfaceType.SmoothNoOutlines
  186. Part1.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
  187. Part1.BrickColor = BrickColor.new("Really black")
  188. Part1.CanCollide = false
  189. Part1.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
  190. Part1.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
  191. Part1.Material = Enum.Material.Metal
  192. Part1.RightSurface = Enum.SurfaceType.SmoothNoOutlines
  193. Part1.TopSurface = Enum.SurfaceType.SmoothNoOutlines
  194. Part1.brickColor = BrickColor.new("Really black")
  195. WeldConstraint2.Parent = Part1
  196. WeldConstraint2.Part0 = Part1
  197. WeldConstraint2.Part1 = MeshPart7
  198. LocalScript3.Parent = Tool0
  199. table.insert(cors,sandbox(LocalScript3,function()
  200. tool = script.Parent
  201. player = game:GetService("Players").LocalPlayer
  202.  
  203. tool.Equipped:Connect(function(mouse)
  204.     print("Tool equipped!")
  205.    
  206.     mouse.Button1Down:Connect(function()
  207.         print("Mouse clicked!")
  208.         tool.GunSound:Play()
  209.        
  210.         if player.Character.Humanoid.Health > 0 then
  211.             local ray = Ray.new(tool.Dispenser.CFrame.p, (mouse.Hit.p - tool.Dispenser.CFrame.p).unit * 600)
  212.             local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)
  213.            
  214.             local beam = Instance.new("Part", game.Workspace)
  215.             beam.BrickColor = player.TeamColor
  216.             beam.Material = Enum.Material.Neon
  217.             beam.Transparency = .3
  218.             beam.Anchored = true
  219.             beam.Locked = true
  220.             beam.CanCollide = false
  221.            
  222.             local distance = (tool.Dispenser.CFrame.p - position).magnitude
  223.             beam.Size = Vector3.new(.3, .3, distance)
  224.             beam.CFrame = CFrame.new(tool.Dispenser.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
  225.            
  226.             game:GetService("Debris"):AddItem(beam, 0.05)
  227.            
  228.             if part then
  229.                 local humanoid = part.Parent:FindFirstChild("Humanoid")
  230.                 if not humanoid then
  231.                     humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  232.                 end
  233.                
  234.                 if humanoid then
  235.                     humanoid.Health = humanoid.Health - 50
  236.                     if humanoid.Health > 0 then
  237.                         player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
  238.                     end
  239.                 end
  240.             end
  241.             wait(0.01)
  242.         end
  243.     end)
  244. end)
  245. end))
  246. Sound4.Name = "GunSound"
  247. Sound4.Parent = Tool0
  248. Sound4.SoundId = "rbxassetid://317556447"
  249. Part5.Name = "Dispenser"
  250. Part5.Parent = Tool0
  251. Part5.CFrame = CFrame.new(54.851696, 1.21925676, -8.25834942, 0.000170309577, -0.0115118213, -0.999942482, 0.000137485142, 0.999942482, -0.0115119321, 1, -0.000135516486, 0.000171881926)
  252. Part5.Orientation = Vector3.new(0.660000026, -89.9899979, 0.00999999978)
  253. Part5.Position = Vector3.new(54.851696, 1.21925676, -8.25834942)
  254. Part5.Rotation = Vector3.new(89.1399994, -89.3899994, 89.1500015)
  255. Part5.Color = Color3.new(1, 0, 0)
  256. Part5.Transparency = 1
  257. Part5.Size = Vector3.new(0.275118023, 0.164782956, 0.114782989)
  258. Part5.BottomSurface = Enum.SurfaceType.Smooth
  259. Part5.BrickColor = BrickColor.new("Really red")
  260. Part5.Material = Enum.Material.Neon
  261. Part5.TopSurface = Enum.SurfaceType.Smooth
  262. Part5.brickColor = BrickColor.new("Really red")
  263. Part5.Shape = Enum.PartType.Cylinder
  264. WeldConstraint6.Parent = Part5
  265. WeldConstraint6.Part0 = Part5
  266. WeldConstraint6.Part1 = MeshPart7
  267. Part7.Parent = Tool0
  268. Part7.CFrame = CFrame.new(54.849308, 0.871716022, -7.64500046, 1, 0, 0, 0, 0, 1, 0, -1, 0)
  269. Part7.Orientation = Vector3.new(-90, 0, 0)
  270. Part7.Position = Vector3.new(54.849308, 0.871716022, -7.64500046)
  271. Part7.Rotation = Vector3.new(-90, 0, 0)
  272. Part7.Size = Vector3.new(0.220000029, 1.57999969, 0.990000963)
  273. Part7.BottomSurface = Enum.SurfaceType.Smooth
  274. Part7.TopSurface = Enum.SurfaceType.Smooth
  275. SpecialMesh8.Parent = Part7
  276. SpecialMesh8.MeshId = "http://www.roblox.com/asset/?id=72012879"
  277. SpecialMesh8.Scale = Vector3.new(1.60000002, 1.60000002, 1.60000002)
  278. SpecialMesh8.TextureId = "http://www.roblox.com/asset/?id=72012859"
  279. SpecialMesh8.MeshType = Enum.MeshType.FileMesh
  280. Script9.Name = "qPerfectionWeld"
  281. Script9.Parent = Tool0
  282. table.insert(cors,sandbox(Script9,function()
  283. -- Created by Quenty (@Quenty, follow me on twitter).
  284. -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
  285. -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
  286.  
  287. --[[ INSTRUCTIONS
  288. - Place in the model
  289. - Make sure model is anchored
  290. - That's it. It will weld the model and all children.
  291.  
  292. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  293. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  294. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  295. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  296. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  297. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  298. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  299. THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
  300.  
  301. This script is designed to be used is a regular script. In a local script it will weld, but it will not attempt to handle ancestory changes.
  302. ]]
  303.  
  304. --[[ DOCUMENTATION
  305. - Will work in tools. If ran more than once it will not create more than one weld.  This is especially useful for tools that are dropped and then picked up again.
  306. - Will work in PBS servers
  307. - Will work as long as it starts out with the part anchored
  308. - Stores the relative CFrame as a CFrame value
  309. - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
  310. - Utilizes a recursive algorith to find all parts in the model
  311. - Will reweld on script reparent if the script is initially parented to a tool.
  312. - Welds as fast as possible
  313. ]]
  314.  
  315. -- qPerfectionWeld.lua
  316. -- Created 10/6/2014
  317. -- Author: Quenty
  318. -- Version 1.0.3
  319.  
  320. -- Updated 10/14/2014 - Updated to 1.0.1
  321. --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
  322.  
  323. -- Updated 10/14/2014 - Updated to 1.0.2
  324. --- Fixed bug fix.
  325.  
  326. -- Updated 10/14/2014 - Updated to 1.0.3
  327. --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
  328.  
  329. local NEVER_BREAK_JOINTS = false -- If you set this to true it will never break joints (this can create some welding issues, but can save stuff like hinges).
  330.  
  331.  
  332. local function CallOnChildren(Instance, FunctionToCall)
  333.     -- Calls a function on each of the children of a certain object, using recursion.  
  334.  
  335.     FunctionToCall(Instance)
  336.  
  337.     for _, Child in next, Instance:GetChildren() do
  338.         CallOnChildren(Child, FunctionToCall)
  339.     end
  340. end
  341.  
  342. local function GetNearestParent(Instance, ClassName)
  343.     -- Returns the nearest parent of a certain class, or returns nil
  344.  
  345.     local Ancestor = Instance
  346.     repeat
  347.         Ancestor = Ancestor.Parent
  348.         if Ancestor == nil then
  349.             return nil
  350.         end
  351.     until Ancestor:IsA(ClassName)
  352.  
  353.     return Ancestor
  354. end
  355.  
  356. local function GetBricks(StartInstance)
  357.     local List = {}
  358.  
  359.     -- if StartInstance:IsA("BasePart") then
  360.     --  List[#List+1] = StartInstance
  361.     -- end
  362.  
  363.     CallOnChildren(StartInstance, function(Item)
  364.         if Item:IsA("BasePart") then
  365.             List[#List+1] = Item;
  366.         end
  367.     end)
  368.  
  369.     return List
  370. end
  371.  
  372. local function Modify(Instance, Values)
  373.     -- Modifies an Instance by using a table.  
  374.  
  375.     assert(type(Values) == "table", "Values is not a table");
  376.  
  377.     for Index, Value in next, Values do
  378.         if type(Index) == "number" then
  379.             Value.Parent = Instance
  380.         else
  381.             Instance[Index] = Value
  382.         end
  383.     end
  384.     return Instance
  385. end
  386.  
  387. local function Make(ClassType, Properties)
  388.     -- Using a syntax hack to create a nice way to Make new items.  
  389.  
  390.     return Modify(Instance.new(ClassType), Properties)
  391. end
  392.  
  393. local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
  394. local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
  395.  
  396. local function HasWheelJoint(Part)
  397.     for _, SurfaceName in pairs(Surfaces) do
  398.         for _, HingSurfaceName in pairs(HingSurfaces) do
  399.             if Part[SurfaceName].Name == HingSurfaceName then
  400.                 return true
  401.             end
  402.         end
  403.     end
  404.    
  405.     return false
  406. end
  407.  
  408. local function ShouldBreakJoints(Part)
  409.     --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
  410.     --  definitely some edge cases.
  411.  
  412.     if NEVER_BREAK_JOINTS then
  413.         return false
  414.     end
  415.    
  416.     if HasWheelJoint(Part) then
  417.         return false
  418.     end
  419.    
  420.     local Connected = Part:GetConnectedParts()
  421.    
  422.     if #Connected == 1 then
  423.         return false
  424.     end
  425.    
  426.     for _, Item in pairs(Connected) do
  427.         if HasWheelJoint(Item) then
  428.             return false
  429.         elseif not Item:IsDescendantOf(script.Parent) then
  430.             return false
  431.         end
  432.     end
  433.    
  434.     return true
  435. end
  436.  
  437. local function WeldTogether(Part0, Part1, JointType, WeldParent)
  438.     --- Weld's 2 parts together
  439.     -- @param Part0 The first part
  440.     -- @param Part1 The second part (Dependent part most of the time).
  441.     -- @param [JointType] The type of joint. Defaults to weld.
  442.     -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
  443.     -- @return The weld created.
  444.  
  445.     JointType = JointType or "Weld"
  446.     local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
  447.    
  448.     local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
  449.     Modify(NewWeld, {
  450.         Name = "qCFrameWeldThingy";
  451.         Part0  = Part0;
  452.         Part1  = Part1;
  453.         C0     = CFrame.new();--Part0.CFrame:inverse();
  454.         C1     = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
  455.         Parent = Part1;
  456.     })
  457.  
  458.     if not RelativeValue then
  459.         RelativeValue = Make("CFrameValue", {
  460.             Parent     = Part1;
  461.             Name       = "qRelativeCFrameWeldValue";
  462.             Archivable = true;
  463.             Value      = NewWeld.C1;
  464.         })
  465.     end
  466.  
  467.     return NewWeld
  468. end
  469.  
  470. local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
  471.     -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
  472.     -- @param MainPart The part to weld the model to (can be in the model).
  473.     -- @param [JointType] The type of joint. Defaults to weld.
  474.     -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
  475.    
  476.     for _, Part in pairs(Parts) do
  477.         if ShouldBreakJoints(Part) then
  478.             Part:BreakJoints()
  479.         end
  480.     end
  481.    
  482.     for _, Part in pairs(Parts) do
  483.         if Part ~= MainPart then
  484.             WeldTogether(MainPart, Part, JointType, MainPart)
  485.         end
  486.     end
  487.  
  488.     if not DoNotUnanchor then
  489.         for _, Part in pairs(Parts) do
  490.             Part.Anchored = false
  491.         end
  492.         MainPart.Anchored = false
  493.     end
  494. end
  495.  
  496. local function PerfectionWeld()
  497.     local Tool = GetNearestParent(script, "Tool")
  498.  
  499.     local Parts = GetBricks(script.Parent)
  500.     local PrimaryPart = Tool and Tool:FindFirstChild("Handle") and Tool.Handle:IsA("BasePart") and Tool.Handle or script.Parent:IsA("Model") and script.Parent.PrimaryPart or Parts[1]
  501.  
  502.     if PrimaryPart then
  503.         WeldParts(Parts, PrimaryPart, "Weld", false)
  504.     else
  505.         warn("qWeld - Unable to weld part")
  506.     end
  507.    
  508.     return Tool
  509. end
  510.  
  511. local Tool = PerfectionWeld()
  512.  
  513.  
  514. if Tool and script.ClassName == "Script" then
  515.     --- Don't bother with local scripts
  516.  
  517.     script.Parent.AncestryChanged:connect(function()
  518.         PerfectionWeld()
  519.     end)
  520. end
  521.  
  522. -- Created by Quenty (@Quenty, follow me on twitter).
  523.  
  524. end))
  525. for i,v in pairs(mas:GetChildren()) do
  526.     v.Parent = game:GetService("Players").LocalPlayer.Backpack
  527.     pcall(function() v:MakeJoints() end)
  528. end
  529. mas:Destroy()
  530. for i,v in pairs(cors) do
  531.     spawn(function()
  532.         pcall(v)
  533.     end)
  534. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top