Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- --Fake event to make stuff like Mouse.KeyDown work
- local Disconnect_Function = function(this)
- this[1].Functions[this[2]] = nil
- end
- local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
- local FakeEvent_Metatable = {__index={
- Connect = function(this,f)
- local i = tostring(math.random(0,10000))
- while this.Functions[i] do
- i = tostring(math.random(0,10000))
- end
- this.Functions[i] = f
- return setmetatable({this,i},Disconnect_Metatable)
- end
- }}
- FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
- local function fakeEvent()
- return setmetatable({Functions={}},FakeEvent_Metatable)
- end
- --Creating fake input objects with fake variables
- local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- FakeMouse.keyUp = FakeMouse.KeyUp
- FakeMouse.keyDown = FakeMouse.KeyDown
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function TriggerEvent(self,ev,...)
- for _,f in pairs(self[ev].Functions) do
- f(...)
- end
- end
- FakeMouse.TriggerEvent = TriggerEvent
- UIS.TriggerEvent = TriggerEvent
- --Client communication
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=RealPlayer then return end
- FakeMouse.Target = io.Target
- FakeMouse.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
- local Mouse = owner:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,RobloxHandled)
- if RobloxHandled then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data every second frame, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- local HB = game:GetService("RunService").Heartbeat
- while true do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- --Wait 2 frames
- for i=1,2 do
- HB:Wait()
- end
- end]==],script)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local RealGame = game
- --Metatable for fake service
- local FakeService_Metatable = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then
- return typeof(s[k])=="function"
- and function(_,...)return s[k](s,...)end or s[k]
- end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
- return setmetatable(t,FakeService_Metatable)
- end
- --Fake game object
- local FakeGame = {
- GetService = function(self,s)
- return rawget(self,s) or RealGame:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = RealGame:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- }
- rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
- FakeGame.service = FakeGame.GetService
- FakeService(FakeGame,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = FakeGame,FakeGame.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")
- Part1 = Instance.new("Part")
- SpecialMesh2 = Instance.new("SpecialMesh")
- Sound3 = Instance.new("Sound")
- Sound4 = Instance.new("Sound")
- PointLight5 = Instance.new("PointLight")
- Sound6 = Instance.new("Sound")
- LocalScript7 = Instance.new("LocalScript")
- LocalScript8 = Instance.new("LocalScript")
- Script9 = Instance.new("Script")
- Tool0.Name = "HyperlaserGun"
- Tool0.Parent = mas
- Tool0.TextureId = "http://www.roblox.com/asset/?id=130093050"
- Tool0.GripPos = Vector3.new(0, -0.100000001, 0.75)
- Tool0.CanBeDropped = false
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.Rotation = Vector3.new(153.539993, -9.7699995, -163.440002)
- Part1.FormFactor = Enum.FormFactor.Custom
- Part1.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
- Part1.CFrame = CFrame.new(0.0399999991, 0, 0.0700000003, -0.944598317, 0.280954868, -0.169695258, 0.327697694, 0.836576641, -0.439038545, 0.0186130833, -0.470323801, -0.88229686)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.Position = Vector3.new(0.0399999991, 0, 0.0700000003)
- Part1.Orientation = Vector3.new(26.039999, -169.110001, 21.3899994)
- SpecialMesh2.Parent = Part1
- SpecialMesh2.MeshId = "http://www.roblox.com/asset/?id=130099641"
- SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
- SpecialMesh2.TextureId = "http://www.roblox.com/asset/?id=130093033"
- SpecialMesh2.MeshType = Enum.MeshType.FileMesh
- SpecialMesh2.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
- Sound3.Name = "Fire"
- Sound3.Parent = Part1
- Sound3.SoundId = "http://www.roblox.com/asset?id=130113322"
- Sound4.Name = "Reload"
- Sound4.Parent = Part1
- Sound4.SoundId = "http://www.roblox.com/asset?id=130113370"
- PointLight5.Parent = Part1
- PointLight5.Color = Color3.new(0, 1, 1)
- PointLight5.Range = 6
- PointLight5.Color = Color3.new(0, 1, 1)
- Sound6.Name = "HitFade"
- Sound6.Parent = Part1
- Sound6.SoundId = "http://www.roblox.com/asset?id=130113415"
- LocalScript7.Name = "ToolScript"
- LocalScript7.Parent = Tool0
- table.insert(cors,sandbox(LocalScript7,function()
- --Rescripted by Luckymaxer
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- ServerControl = Tool:WaitForChild("ServerControl")
- ClientControl = Tool:WaitForChild("ClientControl")
- ClientControl.OnClientInvoke = (function(Mode, Value)
- if Mode == "PlaySound" and Value then
- Value:Play()
- end
- end)
- function InvokeServer(Mode, Value, arg)
- pcall(function()
- ServerControl:InvokeServer(Mode, Value, arg)
- end)
- end
- function Equipped(Mouse)
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- if not Player or not Humanoid or Humanoid.Health == 0 then
- return
- end
- Mouse.Button1Down:connect(function()
- InvokeServer("Click", true, Mouse.Hit.p)
- end)
- end
- local function Unequipped()
- end
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- end))
- LocalScript8.Name = "MouseIcon"
- LocalScript8.Parent = Tool0
- table.insert(cors,sandbox(LocalScript8,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))
- Script9.Parent = Tool0
- table.insert(cors,sandbox(Script9,function()
- --Rescripted by Luckymaxer
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- Players = game:GetService("Players")
- Debris = game:GetService("Debris")
- Speed = 100
- Duration = 1
- NozzleOffset = Vector3.new(0, 0.4, -1.1)
- Sounds = {
- Fire = Handle:WaitForChild("Fire"),
- Reload = Handle:WaitForChild("Reload"),
- HitFade = Handle:WaitForChild("HitFade")
- }
- PointLight = Handle:WaitForChild("PointLight")
- ServerControl = (Tool:FindFirstChild("ServerControl") or Instance.new("RemoteFunction"))
- ServerControl.Name = "ServerControl"
- ServerControl.Parent = Tool
- ClientControl = (Tool:FindFirstChild("ClientControl") or Instance.new("RemoteFunction"))
- ClientControl.Name = "ClientControl"
- ClientControl.Parent = Tool
- ServerControl.OnServerInvoke = (function(player, Mode, Value, arg)
- if player ~= Player or Humanoid.Health == 0 or not Tool.Enabled then
- return
- end
- if Mode == "Click" and Value then
- Activated(arg)
- end
- end)
- function InvokeClient(Mode, Value)
- pcall(function()
- ClientControl:InvokeClient(Player, Mode, Value)
- end)
- end
- function TagHumanoid(humanoid, player)
- local Creator_Tag = Instance.new("ObjectValue")
- Creator_Tag.Name = "creator"
- Creator_Tag.Value = player
- Debris:AddItem(Creator_Tag, 2)
- 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 FindCharacterAncestor(Parent)
- if Parent and Parent ~= game:GetService("Workspace") then
- local humanoid = Parent:FindFirstChild("Humanoid")
- if humanoid then
- return Parent, humanoid
- else
- return FindCharacterAncestor(Parent.Parent)
- end
- end
- return nil
- end
- function GetTransparentsRecursive(Parent, PartsTable)
- local PartsTable = (PartsTable or {})
- for i, v in pairs(Parent:GetChildren()) do
- local TransparencyExists = false
- pcall(function()
- local Transparency = v["Transparency"]
- if Transparency then
- TransparencyExists = true
- end
- end)
- if TransparencyExists then
- table.insert(PartsTable, v)
- end
- GetTransparentsRecursive(v, PartsTable)
- end
- return PartsTable
- end
- function SelectionBoxify(Object)
- local SelectionBox = Instance.new("SelectionBox")
- SelectionBox.Adornee = Object
- SelectionBox.Color = BrickColor.new("Toothpaste")
- SelectionBox.Parent = Object
- return SelectionBox
- end
- local function Light(Object)
- local Light = PointLight:Clone()
- Light.Range = (Light.Range + 2)
- Light.Parent = Object
- end
- function FadeOutObjects(Objects, FadeIncrement)
- repeat
- local LastObject = nil
- for i, v in pairs(Objects) do
- v.Transparency = (v.Transparency + FadeIncrement)
- LastObject = v
- end
- wait()
- until LastObject.Transparency >= 1 or not LastObject
- end
- function Dematerialize(character, humanoid, FirstPart)
- if not character or not humanoid then
- return
- end
- humanoid.WalkSpeed = 0
- local Parts = {}
- for i, v in pairs(character:GetChildren()) do
- if v:IsA("BasePart") then
- v.Anchored = true
- table.insert(Parts, v)
- elseif v:IsA("LocalScript") or v:IsA("Script") then
- v:Destroy()
- end
- end
- local SelectionBoxes = {}
- local FirstSelectionBox = SelectionBoxify(FirstPart)
- Light(FirstPart)
- wait(0.05)
- for i, v in pairs(Parts) do
- if v ~= FirstPart then
- table.insert(SelectionBoxes, SelectionBoxify(v))
- Light(v)
- end
- end
- local ObjectsWithTransparency = GetTransparentsRecursive(character)
- FadeOutObjects(ObjectsWithTransparency, 0.1)
- wait(0.5)
- character:BreakJoints()
- humanoid.Health = 0
- Debris:AddItem(character, 2)
- local FadeIncrement = 0.05
- Delay(0.2, function()
- FadeOutObjects({FirstSelectionBox}, FadeIncrement)
- if character and character.Parent then
- character:Destroy()
- end
- end)
- FadeOutObjects(SelectionBoxes, FadeIncrement)
- end
- function Touched(Projectile, Hit)
- if not Hit or not Hit.Parent then
- return
- end
- local character, humanoid = FindCharacterAncestor(Hit)
- if character and humanoid and character ~= Character then
- local ForceFieldExists = false
- for i, v in pairs(character:GetChildren()) do
- if v:IsA("ForceField") then
- ForceFieldExists = true
- end
- end
- if not ForceFieldExists then
- if Projectile then
- local HitFadeSound = Projectile:FindFirstChild(Sounds.HitFade.Name)
- local torso = humanoid.Torso
- if HitFadeSound and torso then
- HitFadeSound.Parent = torso
- HitFadeSound:Play()
- end
- end
- Dematerialize(character, humanoid, Hit)
- end
- if Projectile and Projectile.Parent then
- Projectile:Destroy()
- end
- end
- end
- function Equipped()
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChild("Humanoid")
- if not Player or not Humanoid or Humanoid.Health == 0 then
- return
- end
- end
- function Activated(target)
- if Tool.Enabled and Humanoid.Health > 0 then
- Tool.Enabled = false
- InvokeClient("PlaySound", Sounds.Fire)
- local HandleCFrame = Handle.CFrame
- local FiringPoint = HandleCFrame.p + HandleCFrame:vectorToWorldSpace(NozzleOffset)
- local ShotCFrame = CFrame.new(FiringPoint, target)
- local LaserShotClone = BaseShot:Clone()
- LaserShotClone.CFrame = ShotCFrame + (ShotCFrame.lookVector * (BaseShot.Size.Z / 2))
- local BodyVelocity = Instance.new("BodyVelocity")
- BodyVelocity.velocity = ShotCFrame.lookVector * Speed
- BodyVelocity.Parent = LaserShotClone
- LaserShotClone.Touched:connect(function(Hit)
- if not Hit or not Hit.Parent then
- return
- end
- Touched(LaserShotClone, Hit)
- end)
- Debris:AddItem(LaserShotClone, Duration)
- LaserShotClone.Parent = game:GetService("Workspace")
- wait(0.6) -- FireSound length
- InvokeClient("PlaySound", Sounds.Reload)
- wait(0.75) -- ReloadSound length
- Tool.Enabled = true
- end
- end
- function Unequipped()
- end
- BaseShot = Instance.new("Part")
- BaseShot.Name = "Effect"
- BaseShot.BrickColor = BrickColor.new("Toothpaste")
- BaseShot.Material = Enum.Material.Plastic
- BaseShot.Shape = Enum.PartType.Block
- BaseShot.TopSurface = Enum.SurfaceType.Smooth
- BaseShot.BottomSurface = Enum.SurfaceType.Smooth
- BaseShot.FormFactor = Enum.FormFactor.Custom
- BaseShot.Size = Vector3.new(0.2, 0.2, 3)
- BaseShot.CanCollide = false
- BaseShot.Locked = true
- SelectionBoxify(BaseShot)
- Light(BaseShot)
- BaseShotSound = Sounds.HitFade:Clone()
- BaseShotSound.Parent = BaseShot
- Tool.Equipped:connect(Equipped)
- Tool.Unequipped:connect(Unequipped)
- end))
- 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
Add Comment
Please, Sign In to add comment