Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created with PenguinAnonymous's compiler
- --PenguinAnonymous is not responsible for damages caused to your game
- --This plugin does not remove things
- --PenguinAnonymous cannot be held resonsible for manual deletion for the purpose of testing
- --Keep in mind, any items that cause errors in compilation will be skipped and documented within the last line of the disclaimer comments
- --Thank you for using my plugin and enjoy :)
- --It is free to use
- --If you use this plugin to create your own, please give me credit
- --Z_V edited my plugin to look like his own and published it without giving me credit, and that makes me very angry
- --Errors:
- local runDummyScript = function(f,scri)
- local oldenv = getfenv(f)
- local newenv = setmetatable({}, {
- __index = function(_, k)
- if k:lower() == 'script' then
- return scri
- else
- return oldenv[k]
- end
- end
- })
- setfenv(f, newenv)
- ypcall(function() f() end)
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- mas.Name = "CompiledModel"
- o1 = Instance.new("Tool")
- o2 = Instance.new("Part")
- o3 = Instance.new("SpecialMesh")
- o4 = Instance.new("Sound")
- o5 = Instance.new("LocalScript")
- o6 = Instance.new("Script")
- o7 = Instance.new("Sound")
- o8 = Instance.new("Animation")
- o9 = Instance.new("LocalScript")
- o1.Name = "Taser"
- o1.Parent = game.Players.LocalPlayer.Backpack
- o1.TextureId = "http://www.roblox.com/asset/?id=99866630"
- o1.GripPos = Vector3.new(0, 0, 0.400000006)
- o1.ToolTip = "Shocker"
- o1.CanBeDropped = false
- o2.Name = "Handle"
- o2.Parent = o1
- o2.Rotation = Vector3.new(0, -89.9700012, 0)
- o2.FormFactor = Enum.FormFactor.Custom
- o2.Size = Vector3.new(0.259999961, 0.590000153, 1.40000045)
- o2.CFrame = CFrame.new(0, 0, 0, 0, 0, -0.999999881, -6.30617142e-05, 1.00000024, 0, 1.00000024, 6.30617142e-05, 0)
- o2.BottomSurface = Enum.SurfaceType.Smooth
- o2.TopSurface = Enum.SurfaceType.Smooth
- o3.Parent = o2
- o3.MeshId = "http://www.roblox.com/asset/?id=99866654"
- o3.Scale = Vector3.new(0.5, 0.5, 0.5)
- o3.TextureId = "http://www.roblox.com/asset/?id=99866675"
- o3.MeshType = Enum.MeshType.FileMesh
- o4.Name = "StunGunLoop"
- o4.Parent = o2
- o4.SoundId = "http://www.roblox.com/asset/?id=101178423"
- o4.Looped = true
- o5.Name = "Taser"
- o5.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- -----------------
- --| Constants |--
- -----------------
- local COOLDOWN = 5 -- Seconds until tool can be used again
- local WIRE_LENGTH = 30
- local WIRE_SPEED = 20
- local WIRE_THICKNESS = 0.1
- local HIT_ZONE_HALF_SIZE = Vector3.new(0.5, 0.5, 0.5) / 2
- local ONE_STEP = 1 / 30
- local AIMING_CFRAME = CFrame.new(0.25, 0, 0.4, 0.8, 0, 0.6, 0, 1, 0, -0.6, 0, 0.8)
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = Game:GetService('Debris')
- local PlayersService = Game:GetService('Players')
- local Tool = script.Parent
- local ToolHandle = Tool.Handle
- local StunScript = WaitForChild(script, 'Stun')
- local ReadyAimAnimation = WaitForChild(script, 'ReadyAim2')
- local StunGunLoopSound = WaitForChild(ToolHandle, 'StunGunLoop')
- local OriginalToolGrip = Tool.Grip
- local MyModel = nil
- local MyHumanoid = nil
- local CreatorTag = nil
- local ReadyAimTrack = nil
- local WireBases = {}
- local Done = false
- local BodyPosition = nil
- -------------------------
- --| Utility Functions |--
- -------------------------
- -- Returns the ancestor that contains a Humanoid, if it exists
- local function FindCharacterAncestor(subject)
- if subject and subject ~= Workspace then
- local humanoid = subject:FindFirstChild('Humanoid')
- if humanoid then
- return subject, humanoid
- else
- return FindCharacterAncestor(subject.Parent)
- end
- end
- return nil
- end
- local function WeldInPlace(part0, part1, name, parent)
- local weld = Instance.new('Weld')
- weld.Part0 = part0
- weld.Part1 = part1
- weld.C0 = CFrame.new()
- weld.C1 = part1.CFrame:inverse() * part0.CFrame
- weld.Name = name or 'Weld'
- weld.Parent = parent or part0
- return weld
- end
- ------------------------
- --| Helper Functions |--
- ------------------------
- local function MakeWireBase(parentPart, weldOffset)
- local wireBase = Instance.new('Part')
- wireBase.Name = "WireBase"
- wireBase.CanCollide = false
- wireBase.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
- wireBase.Size = Vector3.new(0.2, 0.2, 0.2) -- Intentional
- wireBase.BottomSurface = Enum.SurfaceType.Smooth
- wireBase.TopSurface = Enum.SurfaceType.Smooth
- local weld = Instance.new('Weld', wireBase)
- weld.Part0 = parentPart
- weld.Part1 = wireBase
- weld.C0 = CFrame.new(weldOffset)
- local wire = Instance.new('BlockMesh', wireBase)
- wire.Name = 'Wire'
- wire.Scale = Vector3.new(WIRE_THICKNESS, WIRE_THICKNESS, 0)
- wireBase.Parent = parentPart
- return wireBase
- end
- local function UnStick()
- --print("UnStick")
- if MyModel and MyHumanoid then
- local torso = MyModel:FindFirstChild('Torso')
- if torso then
- MyHumanoid.WalkSpeed = 16
- if BodyPosition then
- BodyPosition:Destroy()
- BodyPosition = nil
- end
- end
- end
- end
- local function ShotComplete(playExtras)
- --print("ShotComplete, playExtras:", playExtras)
- if ReadyAimTrack then ReadyAimTrack:Stop() end
- wait(0.1)
- Tool.Grip = OriginalToolGrip
- wait(0.1)
- UnStick()
- if playExtras then
- --TODO: play reload animation
- --TODO: play reload sound
- end
- wait(COOLDOWN)
- Tool.Enabled = true
- end
- local function Stopped(hitPart)
- --print("Stopped:", hitPart)
- if Done then return end
- Done = true
- StunGunLoopSound:Stop()
- if hitPart then
- --TODO: play hit sound
- --TODO: wires flash
- local character, humanoid = FindCharacterAncestor(hitPart.Parent)
- if character ~= MyModel and humanoid and humanoid.Health > 0 then
- local stunScriptClone = StunScript:Clone()
- stunScriptClone.Parent = humanoid
- stunScriptClone.Disabled = false
- end
- else
- --TODO: play out of wire sound
- --TODO: wires disappear
- end
- for _, wireBase in pairs(WireBases) do
- local wire = wireBase:FindFirstChild('Wire')
- if wire then
- wire.Scale = Vector3.new(WIRE_THICKNESS, WIRE_THICKNESS, 0)
- wire.Offset = Vector3.new()
- end
- end
- ShotComplete(true)
- end
- local function FireWire(wireBase, targetPoint)
- --print("FireWire:", wireBase, targetPoint)
- if not wireBase or not targetPoint then return end
- local weld = wireBase:FindFirstChild('Weld')
- if weld then
- --weld.C1 = CFrame.new(Vector3.new(), targetPoint - wireBase.Position)
- wireBase.Anchored = true
- weld:Destroy()
- wireBase.CFrame = CFrame.new(wireBase.Position, targetPoint)
- wait(0) -- Wtf
- WeldInPlace(ToolHandle, wireBase, _, wireBase)
- wireBase.Anchored = false
- end
- local wire = wireBase:FindFirstChild('Wire')
- Done = false
- Spawn(function()
- while wireBase and wire and (wire.Scale.Z * wireBase.Size.Z) < WIRE_LENGTH and not Done do
- -- Check the end of the wire for a hit
- local wireEndPoint = wireBase.CFrame * Vector3.new(0, 0, wire.Offset.Z * 2)
- local ray = Ray.new(wireBase.Position, (wireEndPoint - wireBase.Position))
- local part = Workspace:FindPartOnRay(ray, MyModel)
- if part then
- return Stopped(part)
- else -- No hit, not out of wire, just keep going
- local increment = Vector3.new(0, 0, WIRE_SPEED) -- How many 0.2 lengths each time
- wire.Offset = wire.Offset - (increment * (wireBase.Size.Z / 2))
- wire.Scale = wire.Scale + increment
- end
- wait(ONE_STEP)
- end
- Stopped() -- Out of wire
- end)
- end
- ----------------------
- --| Tool Functions |--
- ----------------------
- local function OnEquipped()
- MyModel = Tool.Parent
- MyHumanoid = MyModel:FindFirstChild('Humanoid')
- CreatorTag.Value = PlayersService:GetPlayerFromCharacter(MyModel)
- -- Make top and bottom wire bases
- local front = -ToolHandle.Size.Z / 2
- table.insert(WireBases, MakeWireBase(ToolHandle, Vector3.new(0, -0.17, front)))
- table.insert(WireBases, MakeWireBase(ToolHandle, Vector3.new(0, 0.17, front)))
- if MyHumanoid then
- -- Preload animations
- ReadyAimTrack = MyHumanoid:LoadAnimation(ReadyAimAnimation)
- end
- end
- local function OnActivated(targetOverride)
- if Tool.Enabled and MyModel and MyHumanoid and MyHumanoid.Health > 0 then
- local torso = MyModel:FindFirstChild('Torso')
- if torso then
- Tool.Enabled = false
- -- Pick a target
- local targetPosition = targetOverride or MyHumanoid.TargetPoint
- -- Freeze our character
- MyHumanoid.WalkSpeed = 0
- BodyPosition = Instance.new('BodyPosition')
- BodyPosition.maxForce = Vector3.new(1e6, 1e6, 1e6)
- BodyPosition.position = torso.Position
- DebrisService:AddItem(BodyPosition, 10)
- BodyPosition.Parent = torso
- -- Face the target horizontally
- torso.CFrame = CFrame.new(torso.Position, Vector3.new(targetPosition.X, torso.Position.Y, targetPosition.Z))
- -- Ready, aim...
- if ReadyAimTrack then
- ReadyAimTrack:Play()
- end
- wait(0.1)
- Tool.Grip = AIMING_CFRAME
- wait(0.1)
- -- Fire!
- StunGunLoopSound:Play()
- for _, wireBase in pairs(WireBases) do
- FireWire(wireBase, targetPosition)
- end
- end
- end
- end
- local function OnUnequipped()
- for _, wireBase in pairs(WireBases) do
- wireBase:Destroy()
- end
- WireBases = {}
- -- Stop animations
- if ReadyAimTrack then ReadyAimTrack:Stop() end
- ShotComplete(false)
- end
- -- Also activate when the Action Button is pressed
- local function OnChildAdded(child)
- if child.Name == 'ActionButtonData' then
- child.Changed:connect(function(newValue)
- local bindable = child:FindFirstChild('GetTargetPosition')
- if bindable and string.sub(newValue, 1, 1) == 'v' then
- local matches = {}
- for match in string.gmatch(newValue, '%d+%.?%d*') do
- table.insert(matches, match)
- end
- if #matches == 4 then
- local screenPosition = Vector2.new(matches[1], matches[2])
- local screenSize = Vector2.new(matches[3], matches[4])
- local targetPosition = bindable:Invoke(screenPosition, screenSize, {MyModel})
- OnActivated(targetPosition)
- end
- end
- end)
- end
- end
- --------------------
- --| Script Logic |--
- --------------------
- CreatorTag = Instance.new('ObjectValue')
- CreatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
- local nameTag = Instance.new('StringValue', CreatorTag)
- nameTag.Name = 'weaponName'
- nameTag.Value = Tool.Name
- local iconTag = Instance.new('StringValue', CreatorTag)
- iconTag.Name = 'weaponIcon'
- iconTag.Value = Tool.TextureId
- CreatorTag.Parent = StunScript
- Tool.Equipped:connect(OnEquipped)
- Tool.Activated:connect(OnActivated)
- Tool.Unequipped:connect(OnUnequipped)
- -- Listen for Action Button Data Object
- for _, child in pairs(Tool:GetChildren()) do
- OnChildAdded(child)
- end
- Tool.ChildAdded:connect(OnChildAdded)
- end,o5)
- end))
- o6.Name = "Stun"
- o6.Parent = o5
- o6.Disabled = true
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- -----------------
- --| Constants |--
- -----------------
- local STUN_TIME = 3 -- Seconds
- local DAMAGE = 3
- local DAMAGE_FREQUENCY = 0.4 -- Seconds
- local ONE_STEP = 1 / 30
- --------------------
- --| WaitForChild |--
- --------------------
- -- Waits for parent.child to exist, then returns it
- local function WaitForChild(parent, childName)
- assert(parent, "ERROR: WaitForChild: parent is nil")
- while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
- return parent[childName]
- end
- -----------------
- --| Variables |--
- -----------------
- local DebrisService = Game:GetService('Debris')
- local Humanoid = script.Parent
- local OriginalWalkSpeed = Humanoid.WalkSpeed
- local HitBindable = Humanoid:FindFirstChild('Hit')
- local ZapSound = WaitForChild(script, 'Zap')
- local CreatorTag = WaitForChild(script, 'creator')
- local StartTime = tick()
- local LastDamageTime = StartTime
- -----------------
- --| Functions |--
- -----------------
- local function ApplyTag(target)
- while target:FindFirstChild('creator') do
- target.creator:Destroy()
- end
- local creatorTagClone = CreatorTag:Clone()
- DebrisService:AddItem(creatorTagClone, 4)
- creatorTagClone.Parent = target
- end
- --------------------
- --| Script Logic |--
- --------------------
- ZapSound.Parent = Humanoid.Torso
- repeat
- local now = tick()
- Humanoid.WalkSpeed = 0
- if now - LastDamageTime > DAMAGE_FREQUENCY then
- if ZapSound.Parent ~= script then
- ZapSound:Play()
- end
- if HitBindable then -- (Battle-specific)
- HitBindable:Invoke(DAMAGE, CreatorTag)
- else
- print("Could not find BindableFunction 'Hit'")
- ApplyTag(Humanoid)
- Humanoid:TakeDamage(DAMAGE)
- end
- LastDamageTime = now
- end
- wait(ONE_STEP)
- until now - StartTime >= STUN_TIME
- Humanoid.WalkSpeed = OriginalWalkSpeed
- ZapSound:Destroy()
- script:Destroy()
- end,o6)
- end))
- o7.Name = "Zap"
- o7.Parent = o6
- o7.SoundId = "http://www.roblox.com/asset/?id=101180005"
- o8.Name = "ReadyAim2"
- o8.Parent = o5
- o8.AnimationId = "http://www.roblox.com/Asset?ID=101097290"
- o9.Name = "MouseIcon"
- o9.Parent = o1
- table.insert(cors,coroutine.create(function()
- wait()
- runDummyScript(function()
- local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
- local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
- local Tool = script.Parent
- local Mouse = nil
- local function UpdateIcon()
- if Mouse then
- Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
- end
- end
- local function OnEquipped(mouse)
- Mouse = mouse
- UpdateIcon()
- end
- local function OnChanged(property)
- if property == 'Enabled' then
- UpdateIcon()
- end
- end
- Tool.Equipped:connect(OnEquipped)
- Tool.Changed:connect(OnChanged)
- end,o9)
- end))
- mas.Parent = workspace
- mas:MakeJoints()
- local mas1 = mas:GetChildren()
- for i=1,#mas1 do
- mas1[i].Parent = script
- ypcall(function() mas1[i]:MakeJoints() end)
- end
- mas:Destroy()
- for i=1,#cors do
- coroutine.resume(cors[i])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement