Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- UnionOperation1 = Instance.new("UnionOperation")
- Sound2 = Instance.new("Sound")
- Sound3 = Instance.new("Sound")
- Sound4 = Instance.new("Sound")
- ManualWeld5 = Instance.new("ManualWeld")
- LocalScript6 = Instance.new("LocalScript")
- Animation7 = Instance.new("Animation")
- Animation8 = Instance.new("Animation")
- BoolValue9 = Instance.new("BoolValue")
- Script10 = Instance.new("Script")
- Script11 = Instance.new("Script")
- Script12 = Instance.new("Script")
- Script13 = Instance.new("Script")
- LocalScript14 = Instance.new("LocalScript")
- LocalScript15 = Instance.new("LocalScript")
- RemoteEvent16 = Instance.new("RemoteEvent")
- RemoteEvent17 = Instance.new("RemoteEvent")
- RemoteEvent18 = Instance.new("RemoteEvent")
- Part19 = Instance.new("Part")
- Script20 = Instance.new("Script")
- BillboardGui21 = Instance.new("BillboardGui")
- ImageLabel22 = Instance.new("ImageLabel")
- Configuration23 = Instance.new("Configuration")
- NumberValue24 = Instance.new("NumberValue")
- NumberValue25 = Instance.new("NumberValue")
- NumberValue26 = Instance.new("NumberValue")
- NumberValue27 = Instance.new("NumberValue")
- NumberValue28 = Instance.new("NumberValue")
- NumberValue29 = Instance.new("NumberValue")
- NumberValue30 = Instance.new("NumberValue")
- Tool0.Name = "MAC-11"
- Tool0.Parent = mas
- Tool0.Grip = CFrame.new(0.602584839, 0.164611056, -0.00915747508, -4.37113883e-08, 0, 1, -0.0253309458, 0.999679148, -1.10725096e-09, -0.999679148, -0.0253309458, -4.36973586e-08)
- Tool0.GripForward = Vector3.new(-1, 1.10725096e-09, 4.36973586e-08)
- Tool0.GripPos = Vector3.new(0.602584839, 0.164611056, -0.00915747508)
- Tool0.GripRight = Vector3.new(-4.37113883e-08, -0.0253309458, -0.999679148)
- Tool0.GripUp = Vector3.new(0, 0.999679148, -0.0253309458)
- UnionOperation1.Name = "Handle"
- UnionOperation1.Parent = Tool0
- UnionOperation1.CFrame = CFrame.new(7.94717693, 0.789977014, 1.28141236, 2.8306229e-43, -1.15222564e-21, -0.999999642, -2.07722702e-22, 0.999999285, -1.15222543e-21, 0.999999642, 2.07722601e-22, 1.08880891e-42)
- UnionOperation1.Orientation = Vector3.new(0, -90, 0)
- UnionOperation1.Position = Vector3.new(7.94717693, 0.789977014, 1.28141236)
- UnionOperation1.Rotation = Vector3.new(90, -89.9499969, 90)
- UnionOperation1.Color = Color3.new(0.388235, 0.372549, 0.384314)
- UnionOperation1.Size = Vector3.new(3.35714221, 1.49999988, 0.214285955)
- UnionOperation1.BrickColor = BrickColor.new("Dark stone grey")
- UnionOperation1.Material = Enum.Material.Metal
- UnionOperation1.brickColor = BrickColor.new("Dark stone grey")
- Sound2.Name = "Equip"
- Sound2.Parent = UnionOperation1
- Sound2.SoundId = "rbxassetid://1498950813"
- Sound2.Volume = 1
- Sound3.Name = "Fire"
- Sound3.Parent = UnionOperation1
- Sound3.SoundId = "rbxassetid://1112854510"
- Sound3.Volume = 10
- Sound4.Name = "Hitmark"
- Sound4.Parent = UnionOperation1
- Sound4.SoundId = "rbxassetid://160432334"
- Sound4.Volume = 10
- ManualWeld5.Name = "Handle-to-Muzzle Strong Joint"
- ManualWeld5.Parent = UnionOperation1
- ManualWeld5.C0 = CFrame.new(0.240074679, -0.940510988, -2.31450462, -1, 0, 0, 0, 1, 0, 0, 0, -1)
- ManualWeld5.C1 = CFrame.new(0.205812052, -1.42078507, 0.0316591151, -1, 0, 0, 0, 1, 0, 0, 0, -1)
- ManualWeld5.Part1 = Part19
- ManualWeld5.part1 = Part19
- LocalScript6.Parent = Tool0
- table.insert(cors,sandbox(LocalScript6,function()
- local CanAttack = true
- script.Parent.Activated:connect(function()
- local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
- if CanAttack == true then
- attack:Play()
- CanAttack = false
- wait(0.7)
- attack:Stop()
- CanAttack = true
- script.Parent.CanDamage.Value = true
- end
- end)
- end))
- Animation7.Name = "Attack"
- Animation7.Parent = LocalScript6
- Animation7.AnimationId = "rbxassetid://3655542892"
- Animation8.Name = "Idle"
- Animation8.Parent = LocalScript6
- Animation8.AnimationId = "rbxassetid://3655548714"
- BoolValue9.Name = "CanDamage"
- BoolValue9.Parent = Tool0
- BoolValue9.Value = true
- Script10.Name = "qPerfectionWeld"
- Script10.Parent = Tool0
- table.insert(cors,sandbox(Script10,function()
- -- Created by Quenty (@Quenty, follow me on twitter).
- -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
- -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
- --[[ INSTRUCTIONS
- - Place in the model
- - Make sure model is anchored
- - That's it. It will weld the model and all children.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- 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.
- ]]
- --[[ DOCUMENTATION
- - 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.
- - Will work in PBS servers
- - Will work as long as it starts out with the part anchored
- - Stores the relative CFrame as a CFrame value
- - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
- - Utilizes a recursive algorith to find all parts in the model
- - Will reweld on script reparent if the script is initially parented to a tool.
- - Welds as fast as possible
- ]]
- -- qPerfectionWeld.lua
- -- Created 10/6/2014
- -- Author: Quenty
- -- Version 1.0.3
- -- Updated 10/14/2014 - Updated to 1.0.1
- --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
- -- Updated 10/14/2014 - Updated to 1.0.2
- --- Fixed bug fix.
- -- Updated 10/14/2014 - Updated to 1.0.3
- --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
- 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).
- local function CallOnChildren(Instance, FunctionToCall)
- -- Calls a function on each of the children of a certain object, using recursion.
- FunctionToCall(Instance)
- for _, Child in next, Instance:GetChildren() do
- CallOnChildren(Child, FunctionToCall)
- end
- end
- local function GetNearestParent(Instance, ClassName)
- -- Returns the nearest parent of a certain class, or returns nil
- local Ancestor = Instance
- repeat
- Ancestor = Ancestor.Parent
- if Ancestor == nil then
- return nil
- end
- until Ancestor:IsA(ClassName)
- return Ancestor
- end
- local function GetBricks(StartInstance)
- local List = {}
- -- if StartInstance:IsA("BasePart") then
- -- List[#List+1] = StartInstance
- -- end
- CallOnChildren(StartInstance, function(Item)
- if Item:IsA("BasePart") then
- List[#List+1] = Item;
- end
- end)
- return List
- end
- local function Modify(Instance, Values)
- -- Modifies an Instance by using a table.
- assert(type(Values) == "table", "Values is not a table");
- for Index, Value in next, Values do
- if type(Index) == "number" then
- Value.Parent = Instance
- else
- Instance[Index] = Value
- end
- end
- return Instance
- end
- local function Make(ClassType, Properties)
- -- Using a syntax hack to create a nice way to Make new items.
- return Modify(Instance.new(ClassType), Properties)
- end
- local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
- local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
- local function HasWheelJoint(Part)
- for _, SurfaceName in pairs(Surfaces) do
- for _, HingSurfaceName in pairs(HingSurfaces) do
- if Part[SurfaceName].Name == HingSurfaceName then
- return true
- end
- end
- end
- return false
- end
- local function ShouldBreakJoints(Part)
- --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
- -- definitely some edge cases.
- if NEVER_BREAK_JOINTS then
- return false
- end
- if HasWheelJoint(Part) then
- return false
- end
- local Connected = Part:GetConnectedParts()
- if #Connected == 1 then
- return false
- end
- for _, Item in pairs(Connected) do
- if HasWheelJoint(Item) then
- return false
- elseif not Item:IsDescendantOf(script.Parent) then
- return false
- end
- end
- return true
- end
- local function WeldTogether(Part0, Part1, JointType, WeldParent)
- --- Weld's 2 parts together
- -- @param Part0 The first part
- -- @param Part1 The second part (Dependent part most of the time).
- -- @param [JointType] The type of joint. Defaults to weld.
- -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
- -- @return The weld created.
- JointType = JointType or "Weld"
- local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
- local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
- Modify(NewWeld, {
- Name = "qCFrameWeldThingy";
- Part0 = Part0;
- Part1 = Part1;
- C0 = CFrame.new();--Part0.CFrame:inverse();
- C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
- Parent = Part1;
- })
- if not RelativeValue then
- RelativeValue = Make("CFrameValue", {
- Parent = Part1;
- Name = "qRelativeCFrameWeldValue";
- Archivable = true;
- Value = NewWeld.C1;
- })
- end
- return NewWeld
- end
- local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
- -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
- -- @param MainPart The part to weld the model to (can be in the model).
- -- @param [JointType] The type of joint. Defaults to weld.
- -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
- for _, Part in pairs(Parts) do
- if ShouldBreakJoints(Part) then
- Part:BreakJoints()
- end
- end
- for _, Part in pairs(Parts) do
- if Part ~= MainPart then
- WeldTogether(MainPart, Part, JointType, MainPart)
- end
- end
- if not DoNotUnanchor then
- for _, Part in pairs(Parts) do
- Part.Anchored = false
- end
- MainPart.Anchored = false
- end
- end
- local function PerfectionWeld()
- local Tool = GetNearestParent(script, "Tool")
- local Parts = GetBricks(script.Parent)
- 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]
- if PrimaryPart then
- WeldParts(Parts, PrimaryPart, "Weld", false)
- else
- warn("qWeld - Unable to weld part")
- end
- return Tool
- end
- local Tool = PerfectionWeld()
- if Tool and script.ClassName == "Script" then
- --- Don't bother with local scripts
- script.Parent.AncestryChanged:connect(function()
- PerfectionWeld()
- end)
- end
- -- Created by Quenty (@Quenty, follow me on twitter).
- end))
- Script11.Parent = Tool0
- table.insert(cors,sandbox(Script11,function()
- script.Parent.blade.Touched:connect(function(p)
- if script.Parent.CanDamage.Value == true then
- script.Parent.CanDamage.Value = false
- p.Parent.Humanoid:TakeDamage(200)
- end
- end)
- end))
- Script12.Parent = Tool0
- table.insert(cors,sandbox(Script12,function()
- script.Parent.Equipped:Connect(function()
- script.Parent.Handle.Equip:Play()
- end)
- end))
- Script13.Name = "Server"
- Script13.Parent = Tool0
- table.insert(cors,sandbox(Script13,function()
- --//Variables\\--
- local tool = script.Parent
- local handle = tool:WaitForChild("Handle")
- local muzzle = tool:WaitForChild("Muzzle")
- local muzzleFlash = muzzle:WaitForChild("MuzzleFlash")
- local muzzleEffect = muzzleFlash:WaitForChild("MuzzleEffect")
- local configs = tool:WaitForChild("Configurations")
- local fireRate = configs:FindFirstChild("FireRate")
- local maxDamage = configs:FindFirstChild("MaxDamage")
- local minDamage = configs:FindFirstChild("MinDamage")
- local velocity = configs:FindFirstChild("Velocity")
- local accuracy = configs:FindFirstChild("Accuracy")
- local specialDuration = configs:FindFirstChild("SpecialDuration")
- local specialRechargeTime = configs:FindFirstChild("SpecialRechargeTime")
- local showDamageText = true
- local debris = game:GetService("Debris")
- local fire = tool:WaitForChild("Fire")
- local activateSpecial = tool:WaitForChild("ActivateSpecial")
- local hit = tool:WaitForChild("Hit")
- --//Custom Functions\\--
- function TagHumanoid(humanoid, player)
- local Creator_Tag = Instance.new("ObjectValue")
- Creator_Tag.Name = "creator"
- Creator_Tag.Value = player
- debris:AddItem(Creator_Tag, 0.3)
- Creator_Tag.Parent = humanoid
- end
- function UntagHumanoid(humanoid)
- for i, v in pairs(humanoid:GetChildren()) do
- if v:IsA("ObjectValue") and v.Name == "creator" then
- v:Destroy()
- end
- end
- end
- function TextEffects(element, floatAmount, direction, style, duration)
- element:TweenPosition(UDim2.new(0, math.random(-40, 40), 0, -floatAmount), direction, style, duration)
- wait(0.5)
- for i = 1, 60 do
- element.TextTransparency = element.TextTransparency + 1/60
- element.TextStrokeTransparency = element.TextStrokeTransparency + 1/60
- wait(1/60)
- end
- element.TextTransparency = element.TextTransparency + 1
- element.TextStrokeTransparency = element.TextStrokeTransparency + 1
- element.Parent:Destroy()
- end
- function DynamicText(damage, criticalPoint, humanoid)
- local bill = Instance.new("BillboardGui", humanoid.Parent.Head)
- bill.Size = UDim2.new(0, 50, 0, 100)
- local part = Instance.new("TextLabel", bill)
- bill.AlwaysOnTop = true
- part.TextColor3 = Color3.fromRGB(255, 0, 0)
- part.Text = damage
- part.Font = Enum.Font.SourceSans
- part.TextStrokeTransparency = 0
- part.Size = UDim2.new(1, 0, 1, 0)
- part.Position = UDim2.new(0, 0, 0, 0)
- part.BackgroundTransparency = 1
- bill.Adornee = bill.Parent
- if damage < criticalPoint then
- part.TextSize = 28
- part.TextColor3 = Color3.new(1, 0, 0)
- elseif damage >= criticalPoint then
- part.TextSize = 32
- part.TextColor3 = Color3.new(1, 1, 0)
- end
- spawn(function()
- TextEffects(part, 85, Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.75)
- end)
- end
- function DamageAndTagHumanoid(player, humanoid, damage)
- hit:FireClient(player)
- UntagHumanoid(handle)
- humanoid:TakeDamage(damage) TagHumanoid(humanoid, player)
- end
- --//Remote Functions\\--
- fire.OnServerEvent:Connect(function(player, mouseHit)
- local character = player.Character
- local humanoid = character:FindFirstChild("Humanoid")
- local weaponAccuracy = Vector3.new(math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2), math.random(-accuracy.Value * 2, accuracy.Value * 2))
- if humanoid and humanoid ~= 0 then
- local projectile = Instance.new("Part", workspace)
- local trail = Instance.new("Trail", projectile)
- trail.FaceCamera = true
- trail.Lifetime = 0.3
- trail.MinLength = 0.15
- trail.LightEmission = 0.25
- local attachment0 = Instance.new("Attachment", projectile)
- attachment0.Position = Vector3.new(0.35, 0, 0)
- attachment0.Name = "Attachment1"
- local attachment1 = Instance.new("Attachment", projectile)
- attachment1.Position = Vector3.new(-0.35, 0, 0)
- attachment1.Name = "Attachment1"
- trail.Attachment0 = attachment0
- trail.Attachment1 = attachment1
- projectile.Name = "Bullet"
- projectile.BrickColor = BrickColor.new("Smoky gray")
- projectile.Shape = "Ball"
- projectile.Material = Enum.Material.Metal
- projectile.TopSurface = 0
- projectile.BottomSurface = 0
- projectile.Size = Vector3.new(1, 1, 1)
- projectile.Transparency = 1
- projectile.CFrame = CFrame.new(muzzle.CFrame.p, mouseHit.p)
- projectile.CanCollide = false
- local transparencyPoints = {}
- local startColor = Color3.new(255, 255, 0)
- local endColor = Color3.new(213, 115, 61)
- table.insert(transparencyPoints, NumberSequenceKeypoint.new(0, 1))
- table.insert(transparencyPoints, NumberSequenceKeypoint.new(0.25, 0))
- table.insert(transparencyPoints, NumberSequenceKeypoint.new(1, 1))
- local determinedTransparency = NumberSequence.new(transparencyPoints)
- local determinedColors = ColorSequence.new(startColor, endColor)
- trail.Transparency = determinedTransparency
- trail.Color = determinedColors
- local bodyVelocity = Instance.new("BodyVelocity", projectile)
- bodyVelocity.MaxForce = Vector3.new(9e9, 9e9, 9e9)
- bodyVelocity.Velocity = (mouseHit.lookVector * velocity.Value) + weaponAccuracy
- debris:AddItem(projectile, 20)
- projectile.Touched:Connect(function(hit)
- local eHumanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
- local damage = math.random(minDamage.Value, maxDamage.Value)
- if not eHumanoid and not hit.Anchored and not hit:IsDescendantOf(character) then
- projectile:Destroy()
- elseif eHumanoid and eHumanoid ~= humanoid and eHumanoid.Health > 0 and hit ~= projectile then
- if hit.Name == "Head" or hit:IsA("Hat") then
- damage = damage * 1.5
- end
- local criticalPoint = maxDamage.Value
- DamageAndTagHumanoid(player, eHumanoid, damage)
- if showDamageText then
- DynamicText(damage, criticalPoint, eHumanoid)
- else
- end
- projectile:Destroy()
- elseif hit.CanCollide == true and not hit:IsDescendantOf(player.Character) and hit.Anchored == true then
- projectile:Destroy()
- end
- end)
- handle.Fire:Play()
- muzzleEffect.Visible = true
- muzzleEffect.Rotation = math.random(-360, 360)
- delay(0.1, function()
- muzzleEffect.Visible = false
- end)
- end
- end)
- activateSpecial.OnServerEvent:Connect(function(player)
- accuracy.Value, fireRate.Value = accuracy.Value / 2, fireRate.Value / 2
- minDamage.Value, maxDamage.Value = minDamage.Value / 2, maxDamage.Value / 2
- spawn(function()
- local chargeSound = Instance.new("Sound", player.PlayerGui)
- chargeSound.Name = "ChargeSound"
- chargeSound.SoundId = "rbxassetid://163619849"
- chargeSound:Play()
- chargeSound.Ended:Connect(function() chargeSound:Destroy() end)
- local sparkles = Instance.new("Sparkles", handle)
- sparkles.SparkleColor = Color3.fromRGB(255, 236, 21)
- local activatedGui = Instance.new("ScreenGui", player.PlayerGui)
- activatedGui.Name = "SpecialActivated"
- local textLabel = Instance.new("TextLabel", activatedGui)
- textLabel.TextColor3 = Color3.fromRGB(0, 180, 30)
- textLabel.Text = "Overkill/BeastMode Activated!"
- textLabel.Font = Enum.Font.SourceSans
- textLabel.TextScaled = true
- textLabel.TextStrokeTransparency = 0
- textLabel.Size = UDim2.new(0, 300, 0, 50)
- textLabel.Position = UDim2.new(2.5, 0, 0.15, -10)
- textLabel.BackgroundTransparency = 1
- textLabel:TweenPosition(UDim2.new(0.5, -(textLabel.Size.X.Offset / 2), 0.1, -10), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 1)
- debris:AddItem(sparkles, specialDuration.Value)
- debris:AddItem(chargeSound, 3)
- wait(3)
- TextEffects(textLabel, 200, Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1)
- end)
- for i = specialDuration.Value, 0, -1 do
- wait(1)
- print("Special activated: "..i)
- end
- accuracy.Value, fireRate.Value = accuracy.Value * 2, fireRate.Value * 2
- minDamage.Value, maxDamage.Value = minDamage.Value * 2, maxDamage.Value * 2
- activateSpecial:FireClient(player)
- end)
- end))
- LocalScript14.Name = "BackupWeld"
- LocalScript14.Parent = Tool0
- table.insert(cors,sandbox(LocalScript14,function()
- function Weld(x,y)
- local W = Instance.new("Weld")
- W.Part0 = x
- W.Part1 = y
- local CJ = CFrame.new(x.Position)
- local C0 = x.CFrame:inverse()*CJ
- local C1 = y.CFrame:inverse()*CJ
- W.C0 = C0
- W.C1 = C1
- W.Parent = x
- end
- function Get(A)
- if A.className == "Part" then
- Weld(script.Parent.Handle, A)
- A.Anchored = false
- else
- local C = A:GetChildren()
- for i=1, #C do
- Get(C[i])
- end
- end
- end
- function Finale()
- Get(script.Parent)
- end
- script.Parent.Equipped:connect(Finale)
- script.Parent.Unequipped:connect(Finale)
- Finale()
- end))
- LocalScript15.Name = "Client"
- LocalScript15.Parent = Tool0
- table.insert(cors,sandbox(LocalScript15,function()
- --//Variables\\--
- local tool = script.Parent
- local handle = tool:WaitForChild("Handle")
- local contextActionService = game:GetService("ContextActionService")
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local character = player.Character or player.CharacterAdded:Wait()
- local enabled = true
- local specialDB = true
- local cursorId = "http://www.roblox.com/asset/?id=251497633"
- local hitId = "http://www.roblox.com/asset/?id=70785856"
- local configs = tool:WaitForChild("Configurations")
- local fireRate = configs:FindFirstChild("FireRate")
- local specialRechargeTime = configs:FindFirstChild("SpecialRechargeTime")
- local fire = tool:WaitForChild("Fire")
- local activateSpecial = tool:WaitForChild("ActivateSpecial")
- local hit = tool:WaitForChild("Hit")
- --//Custom Functions\\--
- function activate()
- if specialDB then
- specialDB = false
- activateSpecial:FireServer()
- else
- end
- end
- --//Tool Function\\--
- tool.Equipped:Connect(function()
- contextActionService:BindAction("ActivateSpecial", activate, true, Enum.KeyCode.E)
- contextActionService:SetImage("ActivateSpecial", tool.TextureId)
- contextActionService:SetPosition("ActivateSpecial", UDim2.new(0.72, -25, 0.20, -25))
- mouse.Icon = cursorId
- end)
- tool.Unequipped:Connect(function()
- contextActionService:UnbindAction("ActivateSpecial")
- mouse.Icon = ""
- end)
- tool.Activated:Connect(function()
- if not enabled then return end
- enabled = false
- fire:FireServer(mouse.Hit)
- wait(fireRate.Value)
- enabled = true
- end)
- hit.OnClientEvent:Connect(function()
- mouse.Icon = hitId
- handle.Hitmark:Play()
- wait(0.075)
- mouse.Icon = cursorId
- end)
- activateSpecial.OnClientEvent:Connect(function()
- for i = specialRechargeTime.Value, 0, -1 do
- wait(1)
- specialDB = false
- print("Recharging: "..i)
- end
- specialDB = true
- end)
- end))
- RemoteEvent16.Name = "ActivateSpecial"
- RemoteEvent16.Parent = Tool0
- RemoteEvent17.Name = "Fire"
- RemoteEvent17.Parent = Tool0
- RemoteEvent18.Name = "Hit"
- RemoteEvent18.Parent = Tool0
- Part19.Name = "Muzzle"
- Part19.Parent = Tool0
- Part19.CFrame = CFrame.new(7.95016527, 1.4021982, -0.40956521, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part19.Position = Vector3.new(7.95016527, 1.4021982, -0.40956521)
- Part19.Transparency = 1
- Part19.Size = Vector3.new(0.0650132671, 0.0650132671, 0.0650132671)
- Part19.Anchored = true
- Part19.BottomSurface = Enum.SurfaceType.Smooth
- Part19.TopSurface = Enum.SurfaceType.Smooth
- Script20.Name = "qPerfectionWeld"
- Script20.Parent = Part19
- table.insert(cors,sandbox(Script20,function()
- -- Created by Quenty (@Quenty, follow me on twitter).
- -- Should work with only ONE copy, seamlessly with weapons, trains, et cetera.
- -- Parts should be ANCHORED before use. It will, however, store relatives values and so when tools are reparented, it'll fix them.
- --[[ INSTRUCTIONS
- - Place in the model
- - Make sure model is anchored
- - That's it. It will weld the model and all children.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- THIS SCRIPT SHOULD BE USED ONLY BY ITSELF. THE MODEL SHOULD BE ANCHORED.
- 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.
- ]]
- --[[ DOCUMENTATION
- - 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.
- - Will work in PBS servers
- - Will work as long as it starts out with the part anchored
- - Stores the relative CFrame as a CFrame value
- - Takes careful measure to reduce lag by not having a joint set off or affected by the parts offset from origin
- - Utilizes a recursive algorith to find all parts in the model
- - Will reweld on script reparent if the script is initially parented to a tool.
- - Welds as fast as possible
- ]]
- -- qPerfectionWeld.lua
- -- Created 10/6/2014
- -- Author: Quenty
- -- Version 1.0.3
- -- Updated 10/14/2014 - Updated to 1.0.1
- --- Bug fix with existing ROBLOX welds ? Repro by asimo3089
- -- Updated 10/14/2014 - Updated to 1.0.2
- --- Fixed bug fix.
- -- Updated 10/14/2014 - Updated to 1.0.3
- --- Now handles joints semi-acceptably. May be rather hacky with some joints. :/
- 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).
- local function CallOnChildren(Instance, FunctionToCall)
- -- Calls a function on each of the children of a certain object, using recursion.
- FunctionToCall(Instance)
- for _, Child in next, Instance:GetChildren() do
- CallOnChildren(Child, FunctionToCall)
- end
- end
- local function GetNearestParent(Instance, ClassName)
- -- Returns the nearest parent of a certain class, or returns nil
- local Ancestor = Instance
- repeat
- Ancestor = Ancestor.Parent
- if Ancestor == nil then
- return nil
- end
- until Ancestor:IsA(ClassName)
- return Ancestor
- end
- local function GetBricks(StartInstance)
- local List = {}
- -- if StartInstance:IsA("BasePart") then
- -- List[#List+1] = StartInstance
- -- end
- CallOnChildren(StartInstance, function(Item)
- if Item:IsA("BasePart") then
- List[#List+1] = Item;
- end
- end)
- return List
- end
- local function Modify(Instance, Values)
- -- Modifies an Instance by using a table.
- assert(type(Values) == "table", "Values is not a table");
- for Index, Value in next, Values do
- if type(Index) == "number" then
- Value.Parent = Instance
- else
- Instance[Index] = Value
- end
- end
- return Instance
- end
- local function Make(ClassType, Properties)
- -- Using a syntax hack to create a nice way to Make new items.
- return Modify(Instance.new(ClassType), Properties)
- end
- local Surfaces = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
- local HingSurfaces = {"Hinge", "Motor", "SteppingMotor"}
- local function HasWheelJoint(Part)
- for _, SurfaceName in pairs(Surfaces) do
- for _, HingSurfaceName in pairs(HingSurfaces) do
- if Part[SurfaceName].Name == HingSurfaceName then
- return true
- end
- end
- end
- return false
- end
- local function ShouldBreakJoints(Part)
- --- We do not want to break joints of wheels/hinges. This takes the utmost care to not do this. There are
- -- definitely some edge cases.
- if NEVER_BREAK_JOINTS then
- return false
- end
- if HasWheelJoint(Part) then
- return false
- end
- local Connected = Part:GetConnectedParts()
- if #Connected == 1 then
- return false
- end
- for _, Item in pairs(Connected) do
- if HasWheelJoint(Item) then
- return false
- elseif not Item:IsDescendantOf(script.Parent) then
- return false
- end
- end
- return true
- end
- local function WeldTogether(Part0, Part1, JointType, WeldParent)
- --- Weld's 2 parts together
- -- @param Part0 The first part
- -- @param Part1 The second part (Dependent part most of the time).
- -- @param [JointType] The type of joint. Defaults to weld.
- -- @param [WeldParent] Parent of the weld, Defaults to Part0 (so GC is better).
- -- @return The weld created.
- JointType = JointType or "Weld"
- local RelativeValue = Part1:FindFirstChild("qRelativeCFrameWeldValue")
- local NewWeld = Part1:FindFirstChild("qCFrameWeldThingy") or Instance.new(JointType)
- Modify(NewWeld, {
- Name = "qCFrameWeldThingy";
- Part0 = Part0;
- Part1 = Part1;
- C0 = CFrame.new();--Part0.CFrame:inverse();
- C1 = RelativeValue and RelativeValue.Value or Part1.CFrame:toObjectSpace(Part0.CFrame); --Part1.CFrame:inverse() * Part0.CFrame;-- Part1.CFrame:inverse();
- Parent = Part1;
- })
- if not RelativeValue then
- RelativeValue = Make("CFrameValue", {
- Parent = Part1;
- Name = "qRelativeCFrameWeldValue";
- Archivable = true;
- Value = NewWeld.C1;
- })
- end
- return NewWeld
- end
- local function WeldParts(Parts, MainPart, JointType, DoNotUnanchor)
- -- @param Parts The Parts to weld. Should be anchored to prevent really horrible results.
- -- @param MainPart The part to weld the model to (can be in the model).
- -- @param [JointType] The type of joint. Defaults to weld.
- -- @parm DoNotUnanchor Boolean, if true, will not unachor the model after cmopletion.
- for _, Part in pairs(Parts) do
- if ShouldBreakJoints(Part) then
- Part:BreakJoints()
- end
- end
- for _, Part in pairs(Parts) do
- if Part ~= MainPart then
- WeldTogether(MainPart, Part, JointType, MainPart)
- end
- end
- if not DoNotUnanchor then
- for _, Part in pairs(Parts) do
- Part.Anchored = false
- end
- MainPart.Anchored = false
- end
- end
- local function PerfectionWeld()
- local Tool = GetNearestParent(script, "Tool")
- local Parts = GetBricks(script.Parent)
- 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]
- if PrimaryPart then
- WeldParts(Parts, PrimaryPart, "Weld", false)
- else
- warn("qWeld - Unable to weld part")
- end
- return Tool
- end
- local Tool = PerfectionWeld()
- if Tool and script.ClassName == "Script" then
- --- Don't bother with local scripts
- script.Parent.AncestryChanged:connect(function()
- PerfectionWeld()
- end)
- end
- -- Created by Quenty (@Quenty, follow me on twitter).
- end))
- BillboardGui21.Name = "MuzzleFlash"
- BillboardGui21.Parent = Part19
- BillboardGui21.Size = UDim2.new(0, 150, 0, 150)
- BillboardGui21.Active = true
- BillboardGui21.MaxDistance = 150
- ImageLabel22.Name = "MuzzleEffect"
- ImageLabel22.Parent = BillboardGui21
- ImageLabel22.Visible = false
- ImageLabel22.Size = UDim2.new(1, 0, 1, 0)
- ImageLabel22.BackgroundColor = BrickColor.new("Institutional white")
- ImageLabel22.BackgroundColor3 = Color3.new(1, 1, 1)
- ImageLabel22.BackgroundTransparency = 1
- ImageLabel22.Image = "rbxassetid://192664810"
- ImageLabel22.ImageTransparency = 1
- Configuration23.Name = "Configurations"
- Configuration23.Parent = Tool0
- NumberValue24.Name = "FireRate"
- NumberValue24.Parent = Configuration23
- NumberValue25.Name = "MinDamage"
- NumberValue25.Parent = Configuration23
- NumberValue25.Value = 40
- NumberValue26.Name = "MaxDamage"
- NumberValue26.Parent = Configuration23
- NumberValue26.Value = 45
- NumberValue27.Name = "Velocity"
- NumberValue27.Parent = Configuration23
- NumberValue27.Value = 625
- NumberValue28.Name = "Accuracy"
- NumberValue28.Parent = Configuration23
- NumberValue28.Value = 5
- NumberValue29.Name = "SpecialDuration"
- NumberValue29.Parent = Configuration23
- NumberValue29.Value = 35
- NumberValue30.Name = "SpecialRechargeTime"
- NumberValue30.Parent = Configuration23
- NumberValue30.Value = 60
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = game:GetService("Players").LocalPlayer.Backpack
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement