Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://github.com/Mokiros/roblox-FE-compatibility
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end --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")
- LocalScript1 = Instance.new("LocalScript")
- Script2 = Instance.new("Script")
- Part3 = Instance.new("Part")
- SpecialMesh4 = Instance.new("SpecialMesh")
- Script5 = Instance.new("Script")
- ObjectValue6 = Instance.new("ObjectValue")
- ObjectValue7 = Instance.new("ObjectValue")
- Tool0.Name = "LaserSpecs"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=100449698"
- Tool0.GripForward = Vector3.new(-0, 1.31134158e-07, -1)
- Tool0.GripPos = Vector3.new(1.53999996, -1.27000034, -1.31999993)
- Tool0.GripUp = Vector3.new(0, 1, 1.31134158e-07)
- LocalScript1.Name = "SpotWeld_Main"
- LocalScript1.Parent = Tool0
- table.insert(cors,sandbox(LocalScript1,function()
- --local mDebugId = game.Workspace.DebugId.Value
- --game.Workspace.DebugId.Value = game.Workspace.DebugId.Value+1
- --print("Running swordscript <"..mDebugId..">")
- -------------------------------------
- -- Makes an RBX::Lua Instance using
- -- a table of key-value pairs to
- -- initialize it. Values with numeric
- -- keys will be parented to the object
- -- and other values will be set
- -- as members of the object.
- function Create(ty)
- return function(data)
- local obj = Instance.new(ty)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- ---------------------------------------
- -- Same as Make, but modifies an existing
- -- object rather than creating ones.
- function Modify(obj, data)
- for k, v in pairs(data) do
- if type(data) == 'number' then
- data.Parent = obj
- else
- data[k] = v
- end
- end
- return obj
- end
- -----------------------------------------
- -- Creates a class which can be instantiated
- -- using `CreateCLASSNAME( ... )`.
- ---usage:
- --class'MyClass'(function(this, arg1)
- -- this.ClassMember = value
- -- function this.ClassMethod(...) ... end
- --end, function(def)
- -- def.StaticMember = value
- -- function def.StaticMethod(...) ... end
- --end)
- --local obj = CreateMyClass(arg1)
- ------------------------------------------
- local function class(name)
- local def = {}
- getfenv(0)[name] = def
- return function(ctor, static)
- local nctor = function(...)
- local this = {}
- if ctor then
- ctor(this, ...)
- end
- return this
- end
- getfenv(0)['Create'..name] = nctor
- if static then static(def) end
- end
- end
- ---------------------------------------------
- -- Signal class for custom-made events
- --API:
- -- Signal:connect(callback)
- -- Signal:fire(...)
- -- Signal:wait()
- ---------------------------------------------
- class'Signal'(function(this)
- local mListeners = {}
- local mWaitObject = Create'BoolValue'{}
- function this:connect(func)
- local connection = {}
- function connection:disconnect()
- mListeners[func] = nil
- end
- mListeners[func] = connection
- return connection
- end
- function this:fire(...)
- --print("Fire evt<"..tostring(this).."> from script<"..mDebugId..">")
- for func, conn in pairs(mListeners) do
- --print("-> "..tostring(func).."( ... )")
- func(...)
- end
- mWaitObject.Value = not mWaitObject.Value
- end
- function this:wait()
- mWaitObject.Changed:wait()
- end
- end)
- --------------------------------------------------
- -- Bin class for cleaning up assets
- --API:
- -- Bin:add(func: Function, ident: String)
- -- Bin:clean(ident: String)
- -- Bin:cleanAll()
- --------------------------------------------------
- class'Bin'(function(this)
- local mGarbage = {}
- function this:add(func, ident)
- ident = ident or '__unnamed'
- if not mGarbage[ident] then
- mGarbage[ident] = {}
- end
- mGarbage[ident][#mGarbage[ident]+1] = func
- end
- function this:clean(ident)
- local listToCall = mGarbage[ident]
- if listToCall then
- for _, func in pairs(listToCall) do
- func()
- end
- mGarbage[ident] = nil
- end
- end
- function this:cleanAll()
- for ident, list in pairs(mGarbage) do
- for _, func in pairs(list) do
- func()
- end
- mGarbage[ident] = nil
- end
- end
- end)
- -----------------------------------------------------
- -- AnimationProvider class for easy loading of
- -- animation assets into animationtracks once
- -- a humanoid is available.
- --API:
- -- AnimationProvider:registerAnimation(ident, assetid)
- -- AnimationProvider:setHumanoid(humanoid)
- -- AnimationProvider:setTool(tool)
- -- AnimationProvider:getAnimation(ident)
- -----------------------------------------------------
- class'AnimationProvider'(function(this)
- local mAnimations = {--[[ident => {AnimationId, CurrentTrack, CurrentAnim} ]]}
- local mCurrentHumanoid = nil
- function this:registerAnimation(ident, assetid)
- --check for an existing copy of the anim
- local existingAnim = Tool.Tool:FindFirstChild('ANIM_'..ident)
- --make the data for this anim
- local animdat = {
- AnimationId = assetid,
- CurrentAnim = existingAnim or Create'Animation'{
- Name = "ANIM_"..ident,
- AnimationId = assetid,
- },
- }
- mAnimations[ident] = animdat
- --if there's a current tool, put it in there
- if Tool.Tool then
- Tool.HUGE_EQUIP_HACK = true
- animdat.CurrentAnim.Parent = Tool.Tool
- Tool.HUGE_EQUIP_HACK = false
- end
- --if there's a humanoid load the animation track
- if mCurrentHumanoid then
- animdat.CurrentTrack = mCurrentHumanoid:LoadAnimation(animdat.CurrentAnim)
- end
- end
- function this:setHumanoid(humanoid)
- mCurrentHumanoid = humanoid
- for _, anim in pairs(mAnimations) do
- anim.CurrentTrack = humanoid:LoadAnimation(anim.CurrentAnim)
- end
- end
- function this:getAnimation(ident)
- local dat = mAnimations[ident]
- if not dat then error("Gear Fatal Error: Animation `"..ident.."` not found") end
- if not dat.CurrentTrack then
- error("Gear Fatal Error: No Humanoid for animation `"..ident.."` to run in")
- end
- return dat.CurrentTrack
- end
- end)
- ----------------------------------------------
- -- SoundProvider class
- -- functions similarily to the animationprovider
- ----------------------------------------------
- class'SoundProvider'(function(this)
- local mSounds = {}
- function this:registerSound(ident, assetid, inpart)
- inpart = inpart or Tool.Tool:FindFirstChild('Handle')
- if not inpart then
- repeat
- inpart = Tool.Tool.ChildAdded:wait()
- until inpart.Name == 'Handle'
- end
- local existingSound = inpart:FindFirstChild('SOUND_'..ident)
- local sounddat = {
- SoundId = assetid,
- CurrentSound = existingSound or Create'Sound'{
- Name = 'SOUND_'..ident,
- SoundId = assetid,
- Parent = inpart,
- },
- }
- mSounds[ident] = sounddat
- end
- function this:getSound(ident)
- local dat = mSounds[ident]
- if dat then
- return dat.CurrentSound
- end
- end
- end)
- ----------------------------------------------
- -- DebounceProvider class -- Prevent events
- -- from happening in too rapid succession
- ----------------------------------------------
- class'DebounceProvider'(function(this)
- local mFlagNameToLastTime = {}
- function this:test(ident, delta)
- local t = tick()
- local lastTime = mFlagNameToLastTime[ident] or 0
- if delta then
- return (t-lastTime) > delta
- else
- return mFlagNameToLastTime[ident]
- end
- end
- function this:set(ident, state)
- if state then
- mFlagNameToLastTime[ident] = state
- elseif state == false then
- mFlagNameToLastTime[ident] = false
- else
- mFlagNameToLastTime[ident] = tick()
- end
- end
- end)
- function TagHumanoid(humanoid)
- if Tool.Player then
- local tag = Create'ObjectValue'{
- Name = "creator",
- Value = Tool.Player,
- Parent = humanoid,
- }
- game.Debris:AddItem(tag, 1)
- end
- end
- ------- wait for any event in a set of events to fire ------
- function WaitForAny(tb)
- local evt = tb
- local conn = {}
- local eventargs = nil
- local waitProxy = Create'BoolValue'{}
- for _, e in pairs(evt) do
- local c = e:connect(function(...)
- for _, c in pairs(conn) do
- c:disconnect()
- end
- eventargs = {...}
- waitProxy.Value = not waitProxy.Value
- end)
- conn[#conn+1] = c
- end
- --
- waitProxy.Changed:wait()
- --
- return unpack(eventargs)
- end
- ----------------------------------------------
- local EmitterPart = nil
- -- Tool singleton class
- --API:
- -- ...
- class'Tool'(nil, function(this)
- --need this here for the animationprovider to use
- this.HUGE_EQUIP_HACK = false
- this.Bin = CreateBin()
- this.AnimationProvider = CreateAnimationProvider()
- this.DebounceProvider = CreateDebounceProvider()
- this.SoundProvider = CreateSoundProvider()
- --general values
- this.Tool = script.Parent
- this.Player = nil
- this.Humanoid = nil
- this.Character = nil
- --============ several flags for the gear
- --nothing
- --some events
- this.Equipped = CreateSignal()
- this.Unequipped = CreateSignal()
- this.OwnerChange = CreateSignal()
- --mouse utility events
- this.MouseClick = CreateSignal()
- this.MouseRelease = CreateSignal()
- this.MouseDoubleClick = CreateSignal()
- this.DoubleClickThreshold = 0.2
- this.MouseDown = false
- this.KeyDown = CreateSignal()
- local mLastClickTime = 0
- script.Parent.Equipped:connect(function(mouse)
- --print("Internal Equipped: Time b: "..time())
- --set up general values in the tool
- this.Mouse = mouse
- local curOwner = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
- if curOwner ~= this.Player then
- this.Player = curOwner
- this.OwnerChange:fire(this.Player)
- end
- this.Character = this.Player.Character
- this.Humanoid = this.Character.Humanoid
- this.AnimationProvider:setHumanoid(this.Humanoid)
- --set up the mouse events
- mouse.Button1Down:connect(function()
- this.MouseDown = true
- local t = tick()
- if (t-mLastClickTime) < this.DoubleClickThreshold then
- --prvent multiple double-clicks in a row
- mLastClickTime = 0
- this.MouseDoubleClick:fire(mouse)
- else
- mLastClickTime = t
- this.MouseClick:fire(mouse)
- end
- end)
- mouse.Button1Up:connect(function()
- this.MouseDown = false
- if EmitterPart then
- EmitterPart:Destroy()
- EmitterPart=nil
- end
- end)
- mouse.KeyDown:connect(function(key)
- this.KeyDown:fire(key)
- end)
- --done setup, call the equipped function
- if this.HUGE_EQUIP_HACK then
- --the HUGE_EQUIP_HACK flags tells the tool that the equip is a synchronous
- --call as a result of parenting an animation to the character, which happens
- --when the tool is picked up from the workspace, but not during normal equips
- --(Why does this happen???), if this is the case, the call should be rederrred
- --one tick to ensure that all of the gear's loading can complete before it's
- --equipped event is called.
- --TODO: Blame John for this.
- Delay(0, function()
- this.Equipped:fire(mouse)
- end)
- else
- --otherwise, proceed as normal
- this.Equipped:fire(mouse)
- end
- end)
- script.Parent.Unequipped:connect(function()
- --before my teardown, fire the event
- this.Unequipped:fire()
- --delete all my garbage
- this.Bin:cleanAll()
- end)
- end)
- local BeamColor = BrickColor.new(Color3.new(255, 0, 0))
- local PartModel = Create'Model'{
- Name = 'SpotWeld_Parts',
- }
- local Failsafe = nil
- Tool.AnimationProvider:registerAnimation('equip', 'http://www.roblox.com/asset/?id=69427262')
- Tool.AnimationProvider:registerAnimation('fire', 'http://www.roblox.com/asset/?id=69427271')
- Tool.AnimationProvider:registerAnimation('hold', 'http://www.roblox.com/asset/?id=69427277')
- class'RaycastIgnore'(nil, function(def)
- local mIgnoreMap = setmetatable({}, {__mode='k'})
- function def:addIgnore(obj)
- mIgnoreMap[obj] = true
- end
- function def:genIgnoreList()
- local ignoreList = {}
- for p, _ in pairs(mIgnoreMap) do
- ignoreList[#ignoreList+1] = p
- for _,t in pairs(p:GetChildren()) do
- if t.Name == 'Effect' then
- ignoreList[#ignoreList+1] = t
- end
- end
- end
- for _, ch in pairs(Tool.Character:GetChildren()) do
- if ch:IsA('BasePart') then
- ignoreList[#ignoreList+1] = ch
- end
- for _, handle in pairs(ch:GetChildren()) do
- if handle:IsA('BasePart') then
- ignoreList[#ignoreList+1] = ch
- end
- end
- end
- return ignoreList
- end
- end)
- class'SpotWeld_Charge'(function(this)
- this.Completed = CreateSignal()
- --
- local mReady = false
- local mSpokeList = {} --[i] = {Direction, Part, Len, Dist}
- local mChargeSphere = nil
- local mFracComplete = 0
- --
- local mLocation;
- --
- local mCurrentRun = 0
- --
- local function genSpokes()
- if mReady then return end
- mReady = true
- --make charge sphere
- mChargeSphere = Create'Part'{
- Name = 'SpotWeld_ChrageSphere',
- FormFactor = 'Custom',
- Anchored = true,
- CanCollide = false,
- Transparency = 0.3,
- BrickColor = BeamColor,
- Create'SpecialMesh'{MeshType='Sphere',},
- }
- RaycastIgnore:addIgnore(mChargeSphere)
- --make new spokes
- for i = 1, 20 do
- local spoke = {}
- spoke.Part = Create'Part'{
- Name = 'SpotWeld_Spoke',
- FormFactor = 'Custom',
- Anchored = true,
- CanCollide = false,
- Transparency = 0.3,
- BrickColor = BeamColor,
- }
- RaycastIgnore:addIgnore(spoke.Part)
- mSpokeList[i] = spoke
- end
- end
- local function randomizeSpokes()
- for _, spoke in pairs(mSpokeList) do
- spoke.Direction = CFrame.new(mLocation)*CFrame.Angles(math.random(-1.14, 1.14),
- math.random(-1.14, 1.14),
- math.random(-1.14, 1.14))
- spoke.Len = math.random()*1+1
- spoke.Dist = math.random()*1+1
- spoke.Part.Size = Vector3.new(0.1, 0.1, spoke.Len)
- end
- end
- local function showSpokes(state)
- if mReady then
- local par = ((state) and PartModel or nil)
- mChargeSphere.Parent = par
- for _, spoke in pairs(mSpokeList) do
- spoke.Part.Parent = par
- end
- end
- end
- local function setSpokes()
- local sphereSz = mFracComplete
- mChargeSphere.Size = Vector3.new(sphereSz, sphereSz, sphereSz)
- mChargeSphere.CFrame = CFrame.new(mLocation)
- --
- for _, spoke in pairs(mSpokeList) do
- local endDistOut = (1-mFracComplete)*spoke.Dist
- local innerDistOut = endDistOut-spoke.Len-sphereSz
- local gotLen;
- if innerDistOut < 0 then
- gotLen = spoke.Len+innerDistOut
- else
- gotLen = spoke.Len
- end
- spoke.Part.Size = Vector3.new(0.1, 0.1, spoke.Len+innerDistOut)
- spoke.Part.CFrame = spoke.Direction*CFrame.new(0, 0, -(endDistOut-gotLen/2))
- end
- end
- --
- function this:run(location)
- mLocation = location
- mCurrentRun = mCurrentRun+1
- local thisRun = mCurrentRun
- mFracComplete = 0
- --
- genSpokes()
- randomizeSpokes()
- showSpokes(true)
- --
- Spawn(function()
- local lastTime = tick()
- while mCurrentRun == thisRun and mFracComplete < 1 do
- local now = tick()
- local dt = now-lastTime
- lastTime = now
- --
- mFracComplete = math.min(1, mFracComplete+dt*2)
- setSpokes()
- --
- wait()
- end
- if mCurrentRun == thisRun then
- showSpokes(false)
- this.Completed:fire()
- end
- end)
- end
- function this:stop()
- showSpokes(false)
- mCurrentRun = mCurrentRun+1
- end
- --
- function this:destroy()
- mReady = false
- mChargeSphere:Destroy()
- for i, spoke in pairs(mSpokeList) do
- mSpokeList[i] = nil
- spoke.Part:Destroy()
- end
- end
- end)
- --[[
- locations:
- C
- /\
- / \
- A B
- locationGetFunc => A, B, C
- ]]
- local function frand(a, b)
- return a+math.random()*(b-a)
- end
- class'WavyBeam'(function(this, numSegs)
- local mSegList = {}
- for i = 1, numSegs do
- mSegList[i] = Create'Part'{
- Name = 'SpotWeld_BeamBit',
- Anchored = true,
- CanCollide = false,
- FormFactor = 'Custom',
- BrickColor = BeamColor,
- Transparency = 0.3,
- }
- RaycastIgnore:addIgnore(mSegList[i])
- end
- function this:show(from, to)
- local totalLen = (from-to).magnitude
- local wave = math.min(totalLen/5, 1)/2
- local dirCF = CFrame.new(from, to)
- local lastPos = dirCF.p --(dirCF*CFrame.new(frand(-wave, wave), frand(-wave, wave), 0)).p
- for i = 1, numSegs do
- local p = mSegList[i]
- p.Parent = PartModel
- local distToThisEnd = i*(totalLen/numSegs)
- local newPos;
- if i == numSegs then
- newPos = (dirCF*CFrame.new(0,0,-distToThisEnd)).p
- else
- newPos = (dirCF*CFrame.new(frand(-wave, wave),
- frand(-wave, wave),
- -distToThisEnd)).p
- end
- p.Size = Vector3.new(0.1, 0.1, totalLen/numSegs)
- p.CFrame = CFrame.new(lastPos, newPos)*CFrame.new(0, 0, -(lastPos-newPos).magnitude/2)
- lastPos = newPos
- end
- end
- function this:hide()
- for i = 1, numSegs do
- mSegList[i].Parent = nil
- end
- end
- end)
- class'SpotWeld_Beam'(function(this)
- local mParticleEmitter = Create'Part'{
- Name = 'SpotWeld_ParticleEmitter',
- Anchored = true,
- CanCollide = false,
- Transparency = 1,
- Create'Sound'{
- Name = 'HoldSound1',
- Looped = true,
- SoundId = 'http://www.roblox.com/asset/?id=100429993',
- Volume=1
- },
- Create'Sound'{
- Name = 'HoldSound2',
- Looped = true,
- SoundId = 'http://www.roblox.com/asset/?id=100429993',
- Volume=1
- },
- }
- RaycastIgnore:addIgnore(mParticleEmitter)
- local mBeam_AC = CreateWavyBeam(2)
- local mBeam_BC = CreateWavyBeam(2)
- --
- local mIsShown = false
- function this:show(a, b, c, showBeam)
- if not a then
- this:hide()
- return
- end
- --
- mBeam_AC:show(a, c)
- mBeam_BC:show(b, c)
- --
- --
- if showBeam then
- --
- mParticleEmitter.Parent = PartModel
- mParticleEmitter.CFrame = CFrame.new(c)
- --
- if not mIsShown then
- mParticleEmitter.HoldSound1:Play()
- Delay(0.5, function() mParticleEmitter.HoldSound2:Play() end)
- end
- mIsShown = true
- else
- if EmitterPart then
- EmitterPart:Destroy()
- EmitterPart=nil
- end
- mParticleEmitter.Parent = nil
- mIsShown = false
- end
- --
- end
- function this:hide()
- mIsShown = false
- --
- mBeam_AC:hide()
- mBeam_BC:hide()
- --
- mParticleEmitter.Parent = nil
- end
- end)
- --effects
- local ChargeEffect = CreateSpotWeld_Charge()
- local BeamEffect = CreateSpotWeld_Beam()
- --helper to show the beam
- function showBeamEffect(target, showBeam)
- local ch = Tool.Character
- local head = ch:FindFirstChild("Head")
- if not (head) then
- BeamEffect:hide()
- end
- --
- local ray = CFrame.new(head.Position, target)*CFrame.new(0, 2, -1)
- local a = (head.CFrame*CFrame.new(-.25, 0, 0)).p
- local b = (head.CFrame*CFrame.new(.25, 0, 0)).p
- local c = target
- --
- --local b = (head.CFrame*CFrame.new(-0.3, 0.15, -0.6)).p
- BeamEffect:show(a, b, c, showBeam)
- end
- function findFaceFromCoord(size, loc)
- local pa, pb = -size/2, size/2
- local dx = math.min(math.abs(loc.x-pa.x), math.abs(loc.x-pb.x))
- local dy = math.min(math.abs(loc.y-pa.y), math.abs(loc.y-pb.y))
- local dz = math.min(math.abs(loc.z-pa.z), math.abs(loc.z-pb.z))
- --
- if dx < dy and dx < dz then
- if math.abs(loc.x-pa.x) < math.abs(loc.x-pb.x) then
- return Enum.NormalId.Left --'Left'
- else
- return Enum.NormalId.Right --'Right'
- end
- elseif dy < dx and dy < dz then
- if math.abs(loc.y-pa.y) < math.abs(loc.y-pb.y) then
- return Enum.NormalId.Bottom --'Bottom'
- else
- return Enum.NormalId.Top --'Top'
- end
- elseif dz < dx and dz < dy then
- if math.abs(loc.z-pa.z) < math.abs(loc.z-pb.z) then
- return Enum.NormalId.Front --'Front'
- else
- return Enum.NormalId.Back --'Back'
- end
- end
- end
- function createFire(part, hit)
- if (part.Parent or game):FindFirstChild("Humanoid") or
- ((part.Parent or game).Parent or game):FindFirstChild("Humanoid") then
- return
- end
- if not EmitterPart then
- EmitterPart = Create'Part'{
- Name = 'EmitPart',
- FormFactor = 'Custom',
- CanCollide = false,
- Anchored = true,
- Size = Vector3.new(.2, .2, .2),
- Transparency = 1,
- Parent = script.Parent,
- }
- RaycastIgnore:addIgnore(EmitterPart)
- local emitScript = script:FindFirstChild('Emitter'):Clone()
- emitScript.Parent=EmitterPart
- emitScript.Disabled = false
- end
- local hitFace = findFaceFromCoord(part.Size, part.CFrame:toObjectSpace(CFrame.new(hit)))
- local dir = (part.CFrame-part.Position)*Vector3.FromNormalId(hitFace)
- if part:IsA('Terrain') then
- EmitterPart.CFrame = CFrame.new(hit)
- else
- EmitterPart.CFrame = CFrame.new(hit, hit+dir)*CFrame.Angles(-math.pi/2, 0, 0)
- end
- game.Debris:AddItem(scorch, 5)
- end
- local mClickNum = 0
- local mSelected = false
- Tool.MouseClick:connect(function()
- mClickNum = mClickNum+1
- local thisClick = mClickNum
- if not Tool.Mouse.Target or not Tool.Character:FindFirstChild("Head") then
- return
- end
- --
- Tool.AnimationProvider:getAnimation('fire'):Play(0, 1, 4)
- Spawn(function()
- repeat until Tool.AnimationProvider:getAnimation('fire').KeyframeReached:wait() == 'complete'
- Tool.AnimationProvider:getAnimation('hold'):Play(0, 1, 1)
- end)
- --
- Tool.Humanoid.WalkSpeed = 0
- --
- local headPos = Tool.Character.Head.Position
- local hit = Tool.Mouse.Hit.p
- ChargeEffect:run((CFrame.new(headPos, hit)*CFrame.new(0, 2, -3)).p)
- ChargeEffect.Completed:wait()
- ChargeEffect:stop()
- --
- local isDamageTick = false
- local timeOfLastScorch = tick()
- local partsToIgnore = RaycastIgnore:genIgnoreList()
- local headPart = Tool.Character:FindFirstChild("Head")
- while mSelected and Tool.MouseDown and mClickNum == thisClick and headPart do
- --first, find the true mouse hit, ignoring my ray parts
- local mouseRay = Tool.Mouse.UnitRay
- local newRay = Ray.new(mouseRay.Origin, mouseRay.Direction.unit*999.9)
- local _, hit = game.Workspace:FindPartOnRayWithIgnoreList(newRay, partsToIgnore)
- --found true hit, now go on to raycast to there from firefrom point
- local headPos = Tool.Character.Head.Position
- local fireFrom = (CFrame.new(headPos, hit)*CFrame.new(0, 2, -1)).p
- local castRay = Ray.new(fireFrom, (hit-fireFrom).unit*999.9)
- local part, target = game.Workspace:FindPartOnRayWithIgnoreList(castRay, partsToIgnore)
- local charHeading = Tool.Character.Torso.CFrame.lookVector
- local outOfFOV = (math.acos((target-fireFrom).unit:Dot(charHeading)) > 1.5)
- if not target or outOfFOV then
- --just shoot arbitrarily ahead
- showBeamEffect((Tool.Character.Head.CFrame*CFrame.new(0, 0, -10)).p, false)
- elseif (target-fireFrom).magnitude > 50 then
- --too far away
- target = fireFrom+(target-fireFrom).unit*50
- showBeamEffect(target, false)
- else
- --mechanism to do more damage every other tick
- isDamageTick = not isDamageTick
- if isDamageTick then
- --see if the target exists and is a humanoid
- local hum = (part.Parent or game):FindFirstChild("Humanoid")
- hum = hum or ((part.Parent or game).Parent or game):FindFirstChild("Humanoid")
- if hum then
- --found a humanoid, do damage
- TagHumanoid(hum)
- hum:TakeDamage(4)
- end
- end
- --make scorch effects
- if (tick()-timeOfLastScorch) > 0.1 then
- timeOfLastScorch = tick()
- createFire(part, target)
- end
- --show the beam
- showBeamEffect(target, true)
- end
- wait()
- end
- if mClickNum == thisClick then
- BeamEffect:hide()
- Tool.Humanoid.WalkSpeed = 16
- Tool.AnimationProvider:getAnimation('hold'):Stop()
- end
- end)
- local mHatPart = nil
- Tool.Equipped:connect(function()
- mSelected = true
- PartModel.Parent = game.Workspace
- Failsafe = Tool.Tool.Failsafe:Clone()
- Failsafe.Disabled = false
- Failsafe.Model.Value = PartModel
- Failsafe.Humanoid.Value = Tool.Humanoid
- Failsafe.Parent = PartModel
- --
- Tool.AnimationProvider:getAnimation('equip'):Play(0.1, 1, 4)
- --Tool.Tool.Grip = CFrame.new()
- Tool.Tool.Handle.Transparency = 1
- --
- Spawn(function()
- --this code causes re-firing of the equipped event fpor some reason?
- --putting it in a new thread fixes this behavior
- mHatPart = Tool.Tool.Handle:Clone()
- mHatPart.Transparency = 0
- mHatPart.Parent = Tool.Character
- local w = Create'Weld'{
- Parent = mHatPart,
- Part0 = mHatPart,
- Part1 = Tool.Character:FindFirstChild('Head'),
- C0 = CFrame.new(0.040000014, 0, 0.0199999996, 1, 0, 0, 0, 1.31134158e-007, 1, 0, -1, 1.31134158e-007),
- C1 = CFrame.new(0, 0.200000003, -0.100000001, 1, 0, 0, 0, -4.37113883e-008, 1, 0, -1, -4.37113883e-008)
- }
- end)
- end)
- Tool.Unequipped:connect(function()
- mSelected = false
- PartModel.Parent = nil
- Failsafe:Destroy()
- Failsafe = nil
- if EmitterPart then
- EmitterPart:Destroy()
- EmitterPart=nil
- end
- --
- Tool.AnimationProvider:getAnimation('equip'):Stop()
- Tool.AnimationProvider:getAnimation('fire'):Stop()
- Tool.AnimationProvider:getAnimation('hold'):Stop()
- --kill any running effects
- ChargeEffect:stop()
- BeamEffect:hide()
- --
- Tool.Humanoid.WalkSpeed = 16
- --Tool.Handle.Transparency = 0
- --
- if mHatPart then
- mHatPart:Destroy()
- mHatPart = nil
- end
- end)
- end))
- Script2.Name = "Emitter"
- Script2.Parent = LocalScript1
- Script2.Disabled = true
- table.insert(cors,sandbox(Script2,function()
- local Particle = Instance.new('Part')
- Particle.Name = 'Effect'
- Particle.Size = Vector3.new(.2,.2,.2)
- Particle.CanCollide = false
- Particle.Transparency = 1
- local PartMesh = Instance.new('SpecialMesh')
- PartMesh.Name = 'PartMesh'
- PartMesh.MeshId = 'http://www.roblox.com/asset/?id=87112830'--'http://www.roblox.com/asset/?id=96501868'--
- PartMesh.TextureId = 'http://www.roblox.com/asset/?id=99871304'
- PartMesh.Parent=Particle
- local PartVelocity = Instance.new('BodyVelocity')
- PartVelocity.maxForce = Vector3.new(99999999,99999999,999999)
- PartVelocity.velocity= Vector3.new(0,1,0)
- PartVelocity.Parent=Particle
- local PartSpin = Instance.new('BodyAngularVelocity')
- PartSpin.maxTorque = Vector3.new(999999999,99999999,999999)
- PartSpin.angularvelocity =Vector3.new(1,1,1)
- PartSpin.Parent=Particle
- local Lifetime = 2
- local Rate =.1
- function TweenTransparency(element,starta,enda,length)
- local startTime = time()
- while time() - startTime < length do
- element.Transparency = ((enda - starta) * ((time() - startTime)/length)) + starta
- wait(.01)
- end
- element.Transparency = enda
- end
- function TweenScale(element,starts,ends,length)
- local startTime = time()
- while time() - startTime < length do
- element.Scale = ((ends - starts) * ((time() - startTime)/length)) + starts
- wait(.01)
- end
- element.Scale = ends
- end
- function TweenColor(element,startc,endc,length)
- local startTime = time()
- while time() - startTime < length do
- element.VertexColor = ((endc - startc) * ((time() - startTime)/length)) + startc
- wait(.01)
- end
- element.VertexColor = endc
- end
- while true do
- PartVelocity.velocity= Vector3.new((math.random()-.5)/2,math.random()+3,(math.random()-.5)/2)
- PartMesh.Scale= Vector3.new((math.random()/2)+.2,math.random()/2+.2,math.random()/2+.2)
- PartSpin.angularvelocity =Vector3.new(math.random()*3,math.random()*3,math.random()*3)
- Particle.CFrame= script.Parent.CFrame
- local npart= Particle:Clone()
- local nmesh = npart:FindFirstChild('PartMesh')
- npart.Transparency = 1
- npart.Parent=script.Parent
- Spawn(function()
- TweenTransparency(npart, 1,.5,.1)
- TweenTransparency(npart, .5,1,1.5)
- end)
- --Spawn(function()
- --TweenColor(nmesh, Vector3.new(.8+(math.random()*.4),1,1),Vector3.new(.5,.5,.5),1.5)
- --end)
- Spawn(function() TweenScale(nmesh,nmesh.Scale,nmesh.Scale*math.random()*.5,1.5) end)
- game.Debris:AddItem(npart,Lifetime)
- wait(Rate)
- end
- end))
- Part3.Name = "Handle"
- Part3.Parent = Tool0
- Part3.FormFactor = Enum.FormFactor.Symmetric
- Part3.Shape = Enum.PartType.Ball
- Part3.Size = Vector3.new(1, 1, 1)
- Part3.CFrame = CFrame.new(80.6800003, 19.2970848, 174.050003, 1, -2.21533113e-17, 9.25474816e-17, 2.21533113e-17, 1, -3.76204621e-17, -9.25474816e-17, 3.76204621e-17, 1)
- Part3.BottomSurface = Enum.SurfaceType.Smooth
- Part3.TopSurface = Enum.SurfaceType.Smooth
- Part3.Position = Vector3.new(80.6800003, 19.2970848, 174.050003)
- SpecialMesh4.Parent = Part3
- SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=1185246"
- SpecialMesh4.Scale = Vector3.new(4, 4, 4)
- SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=5013397"
- SpecialMesh4.MeshType = Enum.MeshType.FileMesh
- SpecialMesh4.Scale = Vector3.new(4, 4, 4)
- Script5.Name = "Failsafe"
- Script5.Parent = Tool0
- Script5.Disabled = true
- table.insert(cors,sandbox(Script5,function()
- while not script:FindFirstChild("Humanoid") do
- script.ChildAdded:wait()
- end
- script.Humanoid.Value.Died:connect(function()
- script.Model.Value:Destroy()
- end)
- end))
- ObjectValue6.Name = "Model"
- ObjectValue6.Parent = Script5
- ObjectValue7.Name = "Humanoid"
- ObjectValue7.Parent = Script5
- 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