Advertisement
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 by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- 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 te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return m:TrigEvent(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
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local Mouse = Player:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a 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 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) 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
- end]==],Player.Character)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __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 _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return rawget(self,s) or _rg:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = _rg: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(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- FakeService(g,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- mouse = game.Players.LocalPlayer:GetMouse()
- gun = Instance.new("Part", game.Players.LocalPlayer.Character)
- gun.Size = Vector3.new(0.5, 1, 2)
- gun.CanCollide = false
- gun:BreakJoints()
- weld = Instance.new("Weld", gun)
- weld.Part0 = game.Players.LocalPlayer.Character["Right Arm"]
- weld.Part1 = gun
- mesh = Instance.new("SpecialMesh", gun)
- mesh.MeshId = "rbxassetid://430056568"
- mesh.TextureId = "rbxassetid://430056584"
- portalmoosic = Instance.new("Sound", game.Players.LocalPlayer.Character)
- portalmoosic.SoundId = "rbxassetid://2174350733"
- portalmoosic.Looped = true
- portalmoosic:Play()
- impact = Instance.new("Sound", game.Players.LocalPlayer.Character)
- impact.SoundId = "rbxassetid://142082170"
- mesh.Scale = Vector3.new(0.17,0.17,0.17)
- weld.C0 = weld.C0 * CFrame.new(-0.2,-1.3,-0.8) * CFrame.Angles(3,0,0)
- local rhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
- rhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
- rhandweld.Part1 = game.Players.LocalPlayer.Character["Right Arm"]
- rhandweld.C0 = CFrame.new(1.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
- rhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0)
- local lhandweld = Instance.new("Weld", game.Players.LocalPlayer.Character.Torso)
- lhandweld.Part0 = game.Players.LocalPlayer.Character.Torso
- lhandweld.Part1 = game.Players.LocalPlayer.Character["Left Arm"]
- lhandweld.C0 = CFrame.new(-1.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
- lhandweld.C1 = CFrame.new(0, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
- Pick = Instance.new("Sound", gun)
- Pick.SoundId = "rbxassetid://291256829"
- Pick:Play()
- Shoot = Instance.new("Sound", gun)
- Shoot.SoundId = "rbxassetid://142774034"
- blueexists = false
- tping = false
- orangeexists = false
- for i = 0,1 , 0.1 do
- wait()
- lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,-0.2,-0.28),i)
- rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.28),i)
- end
- for i = 0,1 , 0.1 do
- wait()
- lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.new(0,-0.25,0),i)
- end
- using = false
- orange = false
- blue = true
- function changeportals(key)
- key = key:lower()
- if key == "q" then
- if not blue then
- blue = true
- orange = false
- end
- end
- if key == "e" then
- if not orange then
- blue = false
- orange = true
- end
- end
- end
- function portal()
- if not using then
- using = true
- if blue then
- Shoot:Play()
- local projectile = Instance.new("Part", workspace)
- projectile.Size = Vector3.new(1,1,1)
- projectile.BrickColor = BrickColor.new("Electric blue")
- projectile.Shape = "Ball"
- projectile.CanCollide = true
- projectile.Anchored = false
- projectile.Material = "Neon"
- local vel = Instance.new("BodyVelocity", projectile)
- vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- vel.Velocity = mouse.Hit.lookVector * 80
- projectile.Position = gun.CFrame.p
- wait(0.03)
- local function make(part)
- local gr = part.Parent:findFirstChild("Part")
- local porjectileposition = projectile.Position
- local portaldoor = Instance.new("Part", workspace)
- portaldoor.Size = Vector3.new(1, 1, 1)
- portaldoor.BrickColor = BrickColor.new("Electric blue")
- portaldoor.Anchored = true
- portaldoor.Shape = "Cylinder"
- portaldoor.Material = "Neon"
- portaldoor.CanCollide = false
- if blueexists == true then
- workspace.BluePortal:destroy()
- end
- blueexists = true
- portaldoor.Name = "BluePortal"
- portaldoor.CFrame = part.CFrame
- if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
- print("if y < x")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
- elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
- print("if x < y")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
- elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
- print("if z < y")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
- end
- portaldoor.Position = projectile.Position
- projectile:destroy()
- for i = 1,18 do
- portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
- wait()
- end
- local function tp(part)
- local hum = part.Parent:findFirstChild("Humanoid")
- if hum ~= nil and blueexists and orangeexists and not tping then
- tping = true
- local tor = part.Parent:findFirstChild("Torso")
- if tor then
- local velocityoftorso = tor.Velocity
- local blport = workspace:findFirstChild("OrangePortal")
- if blport then
- tor.CFrame = workspace.OrangePortal.CFrame
- tor.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
- end
- end
- wait(0.3)
- tping = false
- end
- if not hum and blueexists and orangeexists and not tping then
- tping = true
- local cube = part.Parent:findFirstChild("Cube")
- if cube then
- tping = true
- local velocityoftorso = cube.Velocity
- cube.CFrame = workspace.OrangePortal.CFrame
- cube.Velocity = workspace.OrangePortal.CFrame.rightVector * -velocityoftorso * 1.7
- wait(0.3)
- tping = false
- end
- end
- wait(0.3)
- tping = false
- end
- portaldoor.Touched:connect(tp)
- end
- projectile.Touched:connect(make)
- end
- if orange then
- Shoot:Play()
- local projectile1 = Instance.new("Part", workspace)
- projectile1.Size = Vector3.new(1,1,1)
- projectile1.BrickColor = BrickColor.new("Deep orange")
- projectile1.Shape = "Ball"
- projectile1.CanCollide = true
- projectile1.Anchored = false
- projectile1.Material = "Neon"
- local vel1 = Instance.new("BodyVelocity", projectile1)
- vel1.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- vel1.Velocity = mouse.Hit.lookVector * 80
- projectile1.Position = gun.CFrame.p
- wait(0.03)
- local function make1(part)
- local gr = part.Parent:findFirstChild("Part")
- local portaldoor = Instance.new("Part", workspace)
- portaldoor.Size = Vector3.new(1, 1, 1)
- portaldoor.BrickColor = BrickColor.new("Deep orange")
- portaldoor.Anchored = true
- portaldoor.Material = "Neon"
- portaldoor.Shape = "Cylinder"
- portaldoor.CanCollide = false
- if orangeexists == true then
- workspace.OrangePortal:destroy()
- end
- portaldoor.CFrame = part.CFrame
- if part.Size.y < part.Size.x and part.Size.y < part.Size.z then --a big help from Toxsikkilla
- print("if y < x")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi / 2)
- elseif part.Size.x < part.Size.y and part.Size.x < part.Size.z then
- print("if x < y")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0)
- elseif part.Size.z < part.Size.y and part.Size.z < part.Size.y then
- print("if z < y")
- portaldoor.CFrame = portaldoor.CFrame * CFrame.fromEulerAnglesXYZ(0, math.pi / 2, 0)
- end
- portaldoor.Position = projectile1.Position
- projectile1:destroy()
- for i = 1,18 do
- portaldoor.Size = portaldoor.Size + Vector3.new(0,0.3,0.3)
- wait()
- end
- orangeexists = true
- portaldoor.Name = "OrangePortal"
- local function tp(part)
- local hum = part.Parent:findFirstChild("Humanoid")
- if hum ~= nil and blueexists and orangeexists and not tping then
- tping = true
- local tor = part.Parent:findFirstChild("Torso")
- if tor then
- local velocityoftorso = tor.Velocity
- local blport = workspace:findFirstChild("BluePortal")
- if blport then
- tor.CFrame = workspace.BluePortal.CFrame
- tor.Velocity = workspace.BluePortal.CFrame.rightVector * -velocityoftorso * 1.7
- end
- end
- wait(0.3)
- tping = false
- end
- if not hum and blueexists and orangeexists and not tping then
- tping = true
- local cube = part.Parent:findFirstChild("Cube")
- if cube then
- tping = true
- local velocityoftorso = cube.Velocity
- local blport = workspace:findFirstChild("BluePortal")
- if velocityoftorso.y < velocityoftorso.z and velocityoftorso.y < velocityoftorso.x then
- cube.Velocity = -velocityoftorso * 1.5
- if blport then
- cube.CFrame = workspace.BluePortal.rightVector * -velocityoftorso * 1.7
- end
- end
- wait(0.3)
- tping = false
- end
- wait(0.3)
- tping = false
- end
- wait(0.3)
- tping = false
- end
- portaldoor.Touched:connect(tp)
- end
- projectile1.Touched:connect(make1)
- end
- for i = 0,1 , 0.3 do
- wait()
- lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
- rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
- end
- for i = 0,1 , 0.3 do
- wait()
- lhandweld.C0 = lhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,0.2),i)
- rhandweld.C0 = rhandweld.C0 * CFrame.new():lerp(CFrame.Angles(0,0,-0.2),i)
- end
- using = false
- end
- end
- function remove(key)
- key = key:lower()
- if key == "r" then
- if blueexists or orangeexists or blueexists and orangeexists then
- workspace.OrangePortal:destroy()
- workspace.BluePortal:destroy()
- orangeexists = false
- blueexists = false
- end
- end
- end
- impacting = false
- cubesp = false
- function cubespawn(key)
- key = key:lower()
- if key == "c" then
- if cubesp then
- workspace.Cube:destroy()
- end
- cubesp = true
- local coobe = Instance.new("Part", workspace)
- coobe.Size = Vector3.new(2.774, 2.834, 2.804)
- coobe:BreakJoints()
- coobe.Position = game.Players.LocalPlayer.Character.Torso.Position
- coobe.Name = "Cube"
- local meh = Instance.new("SpecialMesh", coobe)
- meh.MeshId = "rbxassetid://464957313"
- meh.TextureId = "rbxassetid://464957325"
- meh.Scale = Vector3.new(0.8,0.8,0.8)
- local function sounds()
- if not impacting then
- impacting = true
- local impactspeed = math.random(0.9,1.1)
- impact.PlaybackSpeed = impactspeed
- impact:Play()
- wait(0.2)
- impacting = false
- end
- end
- coobe.Touched:connect(sounds)
- end
- end
- function deleterportalsondedth()
- if orangeexists or blueexists or blueexists and orangeexists then
- workspace.OrangePortal:destroy()
- workspace.BluePortal:destroy()
- if cubesp then
- workspace.Cube:destroy()
- end
- end
- end
- game.Players.LocalPlayer.Character.Humanoid.Died:connect(deleterportalsondedth)
- mouse.KeyDown:connect(cubespawn)
- mouse.Button1Down:connect(portal)
- mouse.KeyDown:connect(changeportals)
- mouse.KeyDown:connect(remove)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement