sIendytubble

npc creator

Jun 14th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.65 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  2. local Player,game,owner = owner,game
  3. local RealPlayer = Player
  4. do
  5. print("FE Compatibility code by Mokiros")
  6. local rp = RealPlayer
  7. script.Parent = rp.Character
  8.  
  9. --RemoteEvent for communicating
  10. local Event = Instance.new("RemoteEvent")
  11. Event.Name = "UserInput_Event"
  12.  
  13. --Fake event to make stuff like Mouse.KeyDown work
  14. local function fakeEvent()
  15. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  16. t.connect = t.Connect
  17. return t
  18. end
  19.  
  20. --Creating fake input objects with fake variables
  21. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  22. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  23. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  24. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  25. end}
  26. --Merged 2 functions into one by checking amount of arguments
  27. CAS.UnbindAction = CAS.BindAction
  28.  
  29. --This function will trigger the events that have been :Connect()'ed
  30. local function te(self,ev,...)
  31. local t = m[ev]
  32. if t and t._fakeEvent then
  33. for _,f in pairs(t.Functions) do
  34. f(...)
  35. end
  36. end
  37. end
  38. m.TrigEvent = te
  39. UIS.TrigEvent = te
  40.  
  41. Event.OnServerEvent:Connect(function(plr,io)
  42. if plr~=rp then return end
  43. m.Target = io.Target
  44. m.Hit = io.Hit
  45. if not io.isMouse then
  46. local b = io.UserInputState == Enum.UserInputState.Begin
  47. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  48. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  49. end
  50. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  51. return m:TrigEvent(b and "Button2Down" or "Button2Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67. local Mouse = Player:GetMouse()
  68. local UIS = game:GetService("UserInputService")
  69. local input = function(io,a)
  70. if a then return end
  71. --Since InputObject is a client-side instance, we create and pass table instead
  72. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  73. end
  74. UIS.InputBegan:Connect(input)
  75. UIS.InputEnded:Connect(input)
  76. local h,t
  77. --Give the server mouse data 30 times every second, but only if the values changed
  78. --If player is not moving their mouse, client won't fire events
  79. while wait(1/30) do
  80. if h~=Mouse.Hit or t~=Mouse.Target then
  81. h,t=Mouse.Hit,Mouse.Target
  82. Event:FireServer({isMouse=true,Target=t,Hit=h})
  83. end
  84. end]==],Player.Character)
  85.  
  86. ----Sandboxed game object that allows the usage of client-side methods and services
  87. --Real game object
  88. local _rg = game
  89.  
  90. --Metatable for fake service
  91. local fsmt = {
  92. __index = function(self,k)
  93. local s = rawget(self,"_RealService")
  94. if s then
  95. return typeof(s[k])=="function"
  96. and function(_,...)return s[k](s,...)end or s[k]
  97. end
  98. end,
  99. __newindex = function(self,k,v)
  100. local s = rawget(self,"_RealService")
  101. if s then s[k]=v end
  102. end
  103. }
  104. local function FakeService(t,RealService)
  105. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  106. return setmetatable(t,fsmt)
  107. end
  108.  
  109. --Fake game object
  110. local g = {
  111. GetService = function(self,s)
  112. return rawget(self,s) or _rg:GetService(s)
  113. end,
  114. Players = FakeService({
  115. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  116. },"Players"),
  117. UserInputService = FakeService(UIS,"UserInputService"),
  118. ContextActionService = FakeService(CAS,"ContextActionService"),
  119. RunService = FakeService({
  120. _btrs = {},
  121. RenderStepped = _rg:GetService("RunService").Heartbeat,
  122. BindToRenderStep = function(self,name,_,fun)
  123. self._btrs[name] = self.Heartbeat:Connect(fun)
  124. end,
  125. UnbindFromRenderStep = function(self,name)
  126. self._btrs[name]:Disconnect()
  127. end,
  128. },"RunService")
  129. }
  130. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  131. g.service = g.GetService
  132. FakeService(g,game)
  133. --Changing owner to fake player object to support owner:GetMouse()
  134. game,owner = g,g.Players.LocalPlayer
  135. end
  136. mas = game.Workspace
  137. Model0 = Instance.new("Model")
  138. Part1 = Instance.new("Part")
  139. SpecialMesh2 = Instance.new("SpecialMesh")
  140. Decal3 = Instance.new("Decal")
  141. Sound4 = Instance.new("Sound")
  142. RemoteEvent5 = Instance.new("RemoteEvent")
  143. Sound6 = Instance.new("Sound")
  144. RemoteEvent7 = Instance.new("RemoteEvent")
  145. Sound8 = Instance.new("Sound")
  146. RemoteEvent9 = Instance.new("RemoteEvent")
  147. Sound10 = Instance.new("Sound")
  148. RemoteEvent11 = Instance.new("RemoteEvent")
  149. Sound12 = Instance.new("Sound")
  150. RemoteEvent13 = Instance.new("RemoteEvent")
  151. Sound14 = Instance.new("Sound")
  152. RemoteEvent15 = Instance.new("RemoteEvent")
  153. Sound16 = Instance.new("Sound")
  154. RemoteEvent17 = Instance.new("RemoteEvent")
  155. Sound18 = Instance.new("Sound")
  156. RemoteEvent19 = Instance.new("RemoteEvent")
  157. Sound20 = Instance.new("Sound")
  158. RemoteEvent21 = Instance.new("RemoteEvent")
  159. Part22 = Instance.new("Part")
  160. Decal23 = Instance.new("Decal")
  161. Motor6D24 = Instance.new("Motor6D")
  162. Motor6D25 = Instance.new("Motor6D")
  163. Motor6D26 = Instance.new("Motor6D")
  164. Motor6D27 = Instance.new("Motor6D")
  165. Motor6D28 = Instance.new("Motor6D")
  166. Part29 = Instance.new("Part")
  167. Part30 = Instance.new("Part")
  168. Part31 = Instance.new("Part")
  169. Part32 = Instance.new("Part")
  170. Humanoid33 = Instance.new("Humanoid")
  171. Part34 = Instance.new("Part")
  172. Motor6D35 = Instance.new("Motor6D")
  173. Model0.Name = "NPC"
  174. Model0.Parent = mas
  175. Model0.PrimaryPart = Part1
  176. Part1.Name = "Head"
  177. Part1.Parent = Model0
  178. Part1.CFrame = CFrame.new(-40.985527, 5.29274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  179. Part1.Position = Vector3.new(-40.985527, 5.29274511, 17.6500015)
  180. Part1.Color = Color3.new(0.960784, 0.803922, 0.188235)
  181. Part1.Size = Vector3.new(2, 1, 1)
  182. Part1.BrickColor = BrickColor.new("Bright yellow")
  183. Part1.TopSurface = Enum.SurfaceType.Smooth
  184. Part1.brickColor = BrickColor.new("Bright yellow")
  185. Part1.FormFactor = Enum.FormFactor.Symmetric
  186. Part1.formFactor = Enum.FormFactor.Symmetric
  187. SpecialMesh2.Parent = Part1
  188. SpecialMesh2.Scale = Vector3.new(1.25, 1.25, 1.25)
  189. Decal3.Name = "face"
  190. Decal3.Parent = Part1
  191. Decal3.Texture = "rbxasset://textures/face.png"
  192. Sound4.Name = "GettingUp"
  193. Sound4.Parent = Part1
  194. Sound4.MaxDistance = 150
  195. Sound4.EmitterSize = 5
  196. Sound4.MinDistance = 5
  197. Sound4.SoundId = "rbxasset://sounds/action_get_up.mp3"
  198. Sound4.Volume = 0.64999997615814
  199. RemoteEvent5.Name = "CharacterSoundEvent"
  200. RemoteEvent5.Parent = Sound4
  201. Sound6.Name = "Died"
  202. Sound6.Parent = Part1
  203. Sound6.MaxDistance = 150
  204. Sound6.EmitterSize = 5
  205. Sound6.MinDistance = 5
  206. Sound6.SoundId = "rbxasset://sounds/uuhhh.mp3"
  207. Sound6.Volume = 0.64999997615814
  208. RemoteEvent7.Name = "CharacterSoundEvent"
  209. RemoteEvent7.Parent = Sound6
  210. Sound8.Name = "FreeFalling"
  211. Sound8.Parent = Part1
  212. Sound8.Looped = true
  213. Sound8.TimePosition = 0.54882329892368
  214. Sound8.MaxDistance = 150
  215. Sound8.EmitterSize = 5
  216. Sound8.MinDistance = 5
  217. Sound8.SoundId = "rbxasset://sounds/action_falling.mp3"
  218. Sound8.Volume = 0
  219. RemoteEvent9.Name = "CharacterSoundEvent"
  220. RemoteEvent9.Parent = Sound8
  221. Sound10.Name = "Jumping"
  222. Sound10.Parent = Part1
  223. Sound10.MaxDistance = 150
  224. Sound10.EmitterSize = 5
  225. Sound10.MinDistance = 5
  226. Sound10.SoundId = "rbxasset://sounds/action_jump.mp3"
  227. Sound10.Volume = 0.64999997615814
  228. RemoteEvent11.Name = "CharacterSoundEvent"
  229. RemoteEvent11.Parent = Sound10
  230. Sound12.Name = "Landing"
  231. Sound12.Parent = Part1
  232. Sound12.MaxDistance = 150
  233. Sound12.EmitterSize = 5
  234. Sound12.MinDistance = 5
  235. Sound12.SoundId = "rbxasset://sounds/action_jump_land.mp3"
  236. Sound12.Volume = 1
  237. RemoteEvent13.Name = "CharacterSoundEvent"
  238. RemoteEvent13.Parent = Sound12
  239. Sound14.Name = "Splash"
  240. Sound14.Parent = Part1
  241. Sound14.MaxDistance = 150
  242. Sound14.EmitterSize = 5
  243. Sound14.MinDistance = 5
  244. Sound14.SoundId = "rbxasset://sounds/impact_water.mp3"
  245. Sound14.Volume = 0.64999997615814
  246. RemoteEvent15.Name = "CharacterSoundEvent"
  247. RemoteEvent15.Parent = Sound14
  248. Sound16.Name = "Running"
  249. Sound16.Parent = Part1
  250. Sound16.Looped = true
  251. Sound16.MaxDistance = 150
  252. Sound16.EmitterSize = 5
  253. Sound16.MinDistance = 5
  254. Sound16.Pitch = 1.8500000238419
  255. Sound16.PlaybackSpeed = 1.8500000238419
  256. Sound16.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
  257. Sound16.Volume = 0.64999997615814
  258. RemoteEvent17.Name = "CharacterSoundEvent"
  259. RemoteEvent17.Parent = Sound16
  260. Sound18.Name = "Swimming"
  261. Sound18.Parent = Part1
  262. Sound18.Looped = true
  263. Sound18.MaxDistance = 150
  264. Sound18.EmitterSize = 5
  265. Sound18.MinDistance = 5
  266. Sound18.Pitch = 1.6000000238419
  267. Sound18.PlaybackSpeed = 1.6000000238419
  268. Sound18.SoundId = "rbxasset://sounds/action_swim.mp3"
  269. Sound18.Volume = 0.64999997615814
  270. RemoteEvent19.Name = "CharacterSoundEvent"
  271. RemoteEvent19.Parent = Sound18
  272. Sound20.Name = "Climbing"
  273. Sound20.Parent = Part1
  274. Sound20.Looped = true
  275. Sound20.MaxDistance = 150
  276. Sound20.EmitterSize = 5
  277. Sound20.MinDistance = 5
  278. Sound20.SoundId = "rbxasset://sounds/action_footsteps_plastic.mp3"
  279. Sound20.Volume = 0.64999997615814
  280. RemoteEvent21.Name = "CharacterSoundEvent"
  281. RemoteEvent21.Parent = Sound20
  282. Part22.Name = "Torso"
  283. Part22.Parent = Model0
  284. Part22.CFrame = CFrame.new(-40.985527, 3.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  285. Part22.Position = Vector3.new(-40.985527, 3.79274511, 17.6500015)
  286. Part22.Color = Color3.new(0.2, 0.345098, 0.509804)
  287. Part22.Size = Vector3.new(2, 2, 1)
  288. Part22.BrickColor = BrickColor.new("Storm blue")
  289. Part22.LeftParamA = 0
  290. Part22.LeftParamB = 0
  291. Part22.LeftSurface = Enum.SurfaceType.Weld
  292. Part22.RightParamA = 0
  293. Part22.RightParamB = 0
  294. Part22.RightSurface = Enum.SurfaceType.Weld
  295. Part22.brickColor = BrickColor.new("Storm blue")
  296. Part22.FormFactor = Enum.FormFactor.Symmetric
  297. Part22.formFactor = Enum.FormFactor.Symmetric
  298. Decal23.Name = "roblox"
  299. Decal23.Parent = Part22
  300. Motor6D24.Name = "Right Shoulder"
  301. Motor6D24.Parent = Part22
  302. Motor6D24.MaxVelocity = 0.10000000149012
  303. Motor6D24.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  304. Motor6D24.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  305. Motor6D24.Part0 = Part22
  306. Motor6D24.Part1 = Part30
  307. Motor6D24.part1 = Part30
  308. Motor6D25.Name = "Left Shoulder"
  309. Motor6D25.Parent = Part22
  310. Motor6D25.MaxVelocity = 0.10000000149012
  311. Motor6D25.C0 = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  312. Motor6D25.C1 = CFrame.new(0.5, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  313. Motor6D25.Part0 = Part22
  314. Motor6D25.Part1 = Part29
  315. Motor6D25.part1 = Part29
  316. Motor6D26.Name = "Right Hip"
  317. Motor6D26.Parent = Part22
  318. Motor6D26.MaxVelocity = 0.10000000149012
  319. Motor6D26.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  320. Motor6D26.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
  321. Motor6D26.Part0 = Part22
  322. Motor6D26.Part1 = Part32
  323. Motor6D26.part1 = Part32
  324. Motor6D27.Name = "Left Hip"
  325. Motor6D27.Parent = Part22
  326. Motor6D27.MaxVelocity = 0.10000000149012
  327. Motor6D27.C0 = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  328. Motor6D27.C1 = CFrame.new(-0.5, 1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
  329. Motor6D27.Part0 = Part22
  330. Motor6D27.Part1 = Part31
  331. Motor6D27.part1 = Part31
  332. Motor6D28.Name = "Neck"
  333. Motor6D28.Parent = Part22
  334. Motor6D28.MaxVelocity = 0.10000000149012
  335. Motor6D28.C0 = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  336. Motor6D28.C1 = CFrame.new(0, -0.5, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  337. Motor6D28.Part0 = Part22
  338. Motor6D28.Part1 = Part1
  339. Motor6D28.part1 = Part1
  340. Part29.Name = "Left Arm"
  341. Part29.Parent = Model0
  342. Part29.CFrame = CFrame.new(-42.485527, 3.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  343. Part29.Position = Vector3.new(-42.485527, 3.79274511, 17.6500015)
  344. Part29.Color = Color3.new(0.960784, 0.803922, 0.188235)
  345. Part29.Size = Vector3.new(1, 2, 1)
  346. Part29.BrickColor = BrickColor.new("Bright yellow")
  347. Part29.CanCollide = false
  348. Part29.brickColor = BrickColor.new("Bright yellow")
  349. Part29.FormFactor = Enum.FormFactor.Symmetric
  350. Part29.formFactor = Enum.FormFactor.Symmetric
  351. Part30.Name = "Right Arm"
  352. Part30.Parent = Model0
  353. Part30.CFrame = CFrame.new(-39.485527, 3.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  354. Part30.Position = Vector3.new(-39.485527, 3.79274511, 17.6500015)
  355. Part30.Color = Color3.new(0.960784, 0.803922, 0.188235)
  356. Part30.Size = Vector3.new(1, 2, 1)
  357. Part30.BrickColor = BrickColor.new("Bright yellow")
  358. Part30.CanCollide = false
  359. Part30.brickColor = BrickColor.new("Bright yellow")
  360. Part30.FormFactor = Enum.FormFactor.Symmetric
  361. Part30.formFactor = Enum.FormFactor.Symmetric
  362. Part31.Name = "Left Leg"
  363. Part31.Parent = Model0
  364. Part31.CFrame = CFrame.new(-41.485527, 1.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  365. Part31.Position = Vector3.new(-41.485527, 1.79274511, 17.6500015)
  366. Part31.Color = Color3.new(0.121569, 0.501961, 0.113725)
  367. Part31.Size = Vector3.new(1, 2, 1)
  368. Part31.BottomSurface = Enum.SurfaceType.Smooth
  369. Part31.BrickColor = BrickColor.new("Forest green")
  370. Part31.CanCollide = false
  371. Part31.brickColor = BrickColor.new("Forest green")
  372. Part31.FormFactor = Enum.FormFactor.Symmetric
  373. Part31.formFactor = Enum.FormFactor.Symmetric
  374. Part32.Name = "Right Leg"
  375. Part32.Parent = Model0
  376. Part32.CFrame = CFrame.new(-40.485527, 1.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  377. Part32.Position = Vector3.new(-40.485527, 1.79274511, 17.6500015)
  378. Part32.Color = Color3.new(0.121569, 0.501961, 0.113725)
  379. Part32.Size = Vector3.new(1, 2, 1)
  380. Part32.BottomSurface = Enum.SurfaceType.Smooth
  381. Part32.BrickColor = BrickColor.new("Forest green")
  382. Part32.CanCollide = false
  383. Part32.brickColor = BrickColor.new("Forest green")
  384. Part32.FormFactor = Enum.FormFactor.Symmetric
  385. Part32.formFactor = Enum.FormFactor.Symmetric
  386. Humanoid33.Parent = Model0
  387. Humanoid33.LeftLeg = Part31
  388. Humanoid33.RightLeg = Part32
  389. Humanoid33.Torso = Part34
  390. Part34.Name = "HumanoidRootPart"
  391. Part34.Parent = Model0
  392. Part34.CFrame = CFrame.new(-40.985527, 3.79274511, 17.6500015, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  393. Part34.Position = Vector3.new(-40.985527, 3.79274511, 17.6500015)
  394. Part34.Transparency = 1
  395. Part34.Size = Vector3.new(2, 2, 1)
  396. Part34.BottomSurface = Enum.SurfaceType.Smooth
  397. Part34.CanCollide = false
  398. Part34.LeftParamA = 0
  399. Part34.LeftParamB = 0
  400. Part34.RightParamA = 0
  401. Part34.RightParamB = 0
  402. Part34.TopSurface = Enum.SurfaceType.Smooth
  403. Part34.FormFactor = Enum.FormFactor.Symmetric
  404. Part34.formFactor = Enum.FormFactor.Symmetric
  405. Motor6D35.Name = "RootJoint"
  406. Motor6D35.Parent = Part34
  407. Motor6D35.MaxVelocity = 0.10000000149012
  408. Motor6D35.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  409. Motor6D35.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
  410. Motor6D35.Part0 = Part34
  411. Motor6D35.Part1 = Part22
  412. Motor6D35.part1 = Part22
  413. Model0:MoveTo(game.Players.LocalPlayer.Character.Head.Position)
Add Comment
Please, Sign In to add comment