Guest User

Core.lua

a guest
Jul 19th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.88 KB | None | 0 0
  1. repeat wait() until game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name)
  2. --Set up--
  3. ip = game:GetService("UserInputService")
  4. --game.Players.LocalPlayer.Character:Destroy()
  5. msense = 7
  6. zoomMax = 85
  7. speed = 1.5
  8. ks = {}
  9.  
  10. PLRuse_External_Model = true
  11. ext_md_Dir = game.ReplicatedStorage.plr
  12.  
  13. cam = game.Workspace.CurrentCamera
  14. Mouse = game.Players.LocalPlayer:GetMouse()
  15.  
  16. --Spawn Player--
  17. function plrSpn()
  18.     if PLRuse_External_Model == false then
  19.     --parts--
  20.     plr = Instance.new("Model",game.Workspace)
  21.     plr.Name = "Plr"
  22.     local core = Instance.new("Part",plr)
  23.     core.Name = "Core"
  24.     core.FormFactor = "Custom"
  25.     core.Size = Vector3.new(1,2,2)
  26.     core.BottomSurface = "Smooth"
  27.     core.TopSurface = "Smooth" 
  28.     core.Anchored = false
  29.     core.CanCollide = true     
  30.     core.Position = Vector3.new(0,50,0)
  31.    
  32.     local bg = Instance.new("BodyGyro",plr.Core)   
  33.     local bf = Instance.new("BodyForce",plr.Core)
  34.     bf.force = Vector3.new(0,50,0)
  35.     --welds--
  36.  
  37.     --positions--
  38.    
  39.     elseif  PLRuse_External_Model == true then
  40.    
  41.     plr = ext_md_Dir:clone()   
  42.    
  43.     repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")  
  44.     for i, c in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
  45.         if c.Name ~= "Head" and c.Name ~= "Torso" and c.Name ~= "HumanoidRootPart" and c.Name ~= "Humanoid" then   
  46.         if c:IsA("Part") or c:IsA("BasePart") or c:IsA("CharacterMesh") or c:IsA("ShirtGraphic") or c:IsA("Shirt") or c:IsA("Pants") or c:IsA("Hat") or c:IsA("BodyColors") or c:IsA("Script") or c:IsA("LocalScript")  then c:Destroy() end
  47.             plr.Parent = game.Players.LocalPlayer.Character
  48.         end
  49.     end
  50.    
  51.     plr.Parent = game.Players.LocalPlayer.Character
  52.    
  53.     game.Players.LocalPlayer.Character.Torso.CanCollide = false
  54.     game.Players.LocalPlayer.Character.Head.CanCollide = false
  55.     game.Players.LocalPlayer.Character.HumanoidRootPart.CanCollide = false
  56.     game.Players.LocalPlayer.Character.Head:FindFirstChild("face"):Destroy()
  57.     game.Players.LocalPlayer.Character.Torso.Transparency = 1
  58.     game.Players.LocalPlayer.Character.Head.Transparency = 1
  59.     hum = game.Players.LocalPlayer.Character.Humanoid
  60.     hum.WalkSpeed = 40 
  61.    
  62.     w = Instance.new("Weld",hum)
  63.     w.Part0 = plr.Core
  64.     w.Part1 = hum.Parent.HumanoidRootPart  
  65.    
  66.     local bg = Instance.new("BodyGyro",plr.Core)
  67.     local bf = Instance.new("BodyForce",plr.Core)
  68.     bf.force = Vector3.new(0,-50,0)
  69.     end
  70. end
  71.  
  72. --Character controller--
  73.  
  74. inp = coroutine.wrap(function()
  75.     game:GetService("RunService").RenderStepped:connect(function()
  76.     ip.InputBegan:connect(function(k,p)
  77.             ks[k.KeyCode] = true
  78.         end)
  79.        
  80.     ip.InputEnded:connect(function(k,p)
  81.             ks[k.KeyCode] = false
  82.         end)
  83.     end)
  84. end)
  85.  
  86. plrCnt = coroutine.wrap(function()
  87. game:GetService("RunService").RenderStepped:connect(function()
  88.  
  89. local direction = cam.CoordinateFrame.lookVector
  90.  
  91. plr.Core.Velocity = Vector3.new(0,plr.Core.Velocity.y,0)
  92.  
  93. if ks[Enum.KeyCode.W] and ks[Enum.KeyCode.A] then
  94.        
  95. elseif ks[Enum.KeyCode.W] and ks[Enum.KeyCode.D] then
  96.  
  97. elseif ks[Enum.KeyCode.S] and ks[Enum.KeyCode.A] then
  98.        
  99. elseif ks[Enum.KeyCode.S] and ks[Enum.KeyCode.D] then
  100.        
  101. elseif ks[Enum.KeyCode.W] then
  102.     local test = Vector3.new(plr.Core.Position.x + direction.x*speed,plr.Core.Position.y,plr.Core.Position.z + direction.z*speed)  
  103.     plr:MoveTo(test)   
  104.     plr.Core.CFrame = CFrame.new(plr.Core.Position, plr.Core.Position+Vector3.new(direction.X,0,direction.Z))*CFrame.new(0,0.1,0)
  105. elseif ks[Enum.KeyCode.S] then
  106.     local test = Vector3.new(plr.Core.Position.x + -direction.x*speed,plr.Core.Position.y,plr.Core.Position.z + -direction.z*speed)
  107.     plr:MoveTo(test)   
  108.     plr.Core.CFrame = CFrame.new(plr.Core.Position, plr.Core.Position+Vector3.new(direction.X,0,direction.Z))*CFrame.new(0,0.1,0)  
  109. elseif ks[Enum.KeyCode.A] then
  110.     plr.Core.CFrame = CFrame.new(plr.Core.Position, plr.Core.Position+Vector3.new(direction.X,0,direction.Z))*CFrame.new(0,0.1,0)
  111.     --plr.Core.Velocity = Vector3.new(direction.z*-speed,plr.Core.Velocity.y,direction.x*-speed)   
  112. elseif ks[Enum.KeyCode.D] then
  113.     plr.Core.CFrame = CFrame.new(plr.Core.Position, plr.Core.Position+Vector3.new(direction.X,0,direction.Z))*CFrame.new(0,0.1,0)
  114.     --plr.Core.Velocity = Vector3.new(direction.z*speed,plr.Core.Velocity.y,direction.x*speed)
  115.    
  116. end
  117. end)
  118. end)
  119.  
  120. camCnt = coroutine.wrap(function()
  121.     cam.CameraType = Enum.CameraType.Scriptable
  122.     cam.CoordinateFrame = CFrame.new(plr.Core.Position+Vector3.new(0,20,60))
  123.     wait(1)
  124.     ip.MouseBehavior = Enum.MouseBehavior.LockCenter
  125.     game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson  
  126.    
  127.     local angleX = 0
  128.     local angleY = 0
  129.  
  130. ip.InputChanged:connect(function(inputObject)
  131.     if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
  132.         if inputObject.Delta.x < 0 then
  133.             angleX = angleX - 1 * msense
  134.         elseif inputObject.Delta.x > 0 then
  135.             angleX = angleX + 1 * msense
  136.         end
  137.         if inputObject.Delta.y < 0 then
  138.             angleY = angleY - 1 * msense
  139.         elseif inputObject.Delta.y > 0 then
  140.             angleY = angleY + 1 * msense
  141.         end
  142.     end
  143. end)   
  144.    
  145. game:GetService("RunService").RenderStepped:connect(function()
  146.                
  147.                 if angleY > zoomMax then
  148.                     angleY = zoomMax
  149.                 elseif angleY < -zoomMax then
  150.                     angleY = -zoomMax
  151.                 end
  152.                
  153.                 local x = 5 * math.cos(math.rad(angleX))
  154.                 local z = 5 * math.sin(math.rad(angleX))
  155.                 local y = 2.5 * math.tan(math.rad(angleY))
  156.                
  157.                 local camPosition = Vector3.new(x, y, z)
  158.                 camPosition = camPosition + plr.Core.Position  
  159.                
  160.                 cam.CoordinateFrame = CFrame.new(camPosition, plr.Core.Position)*CFrame.new(0,2,3)         
  161.     end)
  162. end)
  163.  
  164. bounds = coroutine.wrap(function()
  165.     game:GetService("RunService").RenderStepped:connect(function()
  166.         if plr.Core.Position.Y < -50 then
  167.             plr.Core.CFrame = CFrame.new(0,10,0)
  168.             plr.Core.Velocity = Vector3.new(0,0,0)
  169.         elseif plr.Core.Position.Y > 10000 then
  170.             plr.Core.CFrame = CFrame.new(0,10,0)
  171.             plr.Core.Velocity = Vector3.new(0,0,0)
  172.         end
  173.     end)
  174. end)
  175.  
  176. wait(2)
  177.  
  178. plrSpn()
  179. inp()
  180. plrCnt()
  181. camCnt()
  182. bounds()
Advertisement
Add Comment
Please, Sign In to add comment