Advertisement
ForkFullFight

Test

Sep 4th, 2023 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. local plrs=game:FindFirstChildOfClass("Players")
  3. local rs=game:FindFirstChildOfClass("RunService")
  4. local ws=game:FindFirstChildOfClass("Workspace")
  5. local uis=game:FindFirstChildOfClass("UserInputService")
  6. local gs=game:FindFirstChildOfClass("GuiService")
  7. local cg=game:FindFirstChildOfClass("CoreGui")
  8.  
  9. local lp=plrs.LocalPlayer
  10. local pg=lp:FindFirstChildOfClass("PlayerGui")
  11. local mouse=lp:GetMouse()
  12. local stepped=rs.Stepped
  13. local heartbeat=rs.Heartbeat
  14. local renderstepped=rs.RenderStepped
  15.  
  16. local osclock=os.clock
  17. local tspawn=task.spawn
  18. local twait=task.wait
  19. local schar=string.char
  20. local sbyte=string.byte
  21. local ssub=string.sub
  22. local sfind=string.find
  23. local supper=string.upper
  24. local mrandom=math.random
  25. local clamp=math.clamp
  26. local sin=math.sin
  27. local cos=math.cos
  28. local abs=math.abs
  29. local rad=math.rad
  30. local tinsert=table.insert
  31. local tclear=table.clear
  32. local tfind=table.find
  33. local tunpack=table.unpack
  34.  
  35. local i=Instance.new
  36. local v2=Vector2.new
  37. local v3=Vector3.new
  38. local c3=Color3.new
  39. local cf=CFrame.new
  40. local angles=CFrame.Angles
  41. local u2=UDim2.new
  42. local e=Enum
  43. local cs=ColorSequence.new
  44. local csk=ColorSequenceKeypoint.new
  45.  
  46. local sine=osclock()
  47. local deltaTime=0
  48. local v3_0=v3(0,0,0)
  49. local v3_101=v3(1,0,1)
  50. local v3_010=v3(0,1,0)
  51. local v3_001=v3(0,0,1)
  52. local cf_0=cf(0,0,0)
  53. local v3_xz=v3_101*10
  54. local v3_net=v3_010*25.01
  55.  
  56. local function makepcall(f)
  57. if type(f)=="function" then
  58. return function(...)
  59. local a={...}
  60. local r=nil
  61. pcall(function()
  62. r={f(tunpack(a))}
  63. end)
  64. return tunpack(r or {})
  65. end
  66. end
  67. return function() end
  68. end
  69. local function rs(l)
  70. l=l or mrandom(8,15)
  71. local s=""
  72. for i=1,l do
  73. if mrandom(1,2)==1 then
  74. s=s..schar(mrandom(65,90))
  75. else
  76. s=s..schar(mrandom(97,122))
  77. end
  78. end
  79. return s
  80. end
  81. local function gp(p,n,cl)
  82. if typeof(p)=="Instance" then
  83. local c=p:GetChildren()
  84. for i=1,#c do
  85. local v=c[i]
  86. if (v.Name==n) and v:IsA(cl) then
  87. return v
  88. end
  89. end
  90. end
  91. return nil
  92. end
  93. local function loopgp(...)
  94. while true do
  95. local r=gp(...)
  96. if r then
  97. return r
  98. end
  99. twait()
  100. end
  101. end
  102. local function timegp(p,n,c,t)
  103. t=osclock()+t
  104. while t>osclock() do
  105. local r=gp(p,n,c)
  106. if r then
  107. return r
  108. end
  109. twait()
  110. end
  111. return nil
  112. end
  113. local function getNetlessVelocity(realVel)
  114. --if true then return v3_0 end
  115. --if true then return realPartVelocity end
  116. --if true then return v3_net end
  117. if realVel.Magnitude>25.01 then
  118. realVel=realVel.Unit*25.01
  119. end
  120. return realVel*v3_xz+v3_net
  121. end
  122. local isClientInstance=makepcall(function(i)
  123. return ssub(i:GetDebugId(),1,1)=="0"
  124. end)
  125. local isServerInstance=function(i)
  126. return not isClientInstance(i)
  127. end
  128. local shp=(((type(getfenv)=="function") and getfenv()) or {}).sethiddenproperty
  129.  
  130. local allowshiftlock=nil
  131. local ctrltp=nil
  132. local simrad=nil
  133. local placeholders=nil
  134. local clickfling=nil
  135.  
  136. local stopreanimate=function() return nil end
  137. local function reanimate()
  138. --[[
  139. FDless reanimate by MyWorld
  140. aka no client sided instances
  141. "what else do i optimize here"
  142. ]]
  143.  
  144. local novoid = true --prevents parts from going under workspace.FallenPartsDestroyHeight if you control them
  145. local placeholders = true --makes client sided accessories replacing the real ones when unavailable
  146. local speedlimit = 3000 --makes your parts move slower if the magnitude of their velocity is higher than this
  147. local antiragdoll = true --removes instances that are usually used for ragdolling form your character
  148. local addPartsOnRun = false --allows u to add more parts and joints to the simulation after it started
  149. local R15toR6 = true --adds fake r6 parts and joints for animations if your character is r15
  150. local walkSpeed = 16 --your walkspeed (can be changed at runtime)
  151. local jumpPower = 50 --your jump power (can be changed at runtime)
  152. local allowshiftlock = true --allows the user to use shiftlock (can be changed at runtime)
  153. local gravity = 196.2 --how fast the characters velocity increases while falling (can be changed at runtime)
  154. local simrad = "shp" --sets simulation radius to this with sethiddenproperty if its set to a number
  155. local ctrlclicktp = false --makes you teleport where u point ur mouse cursor at when click and hold ctrl down
  156. local clickfling = true --makes you fling the person you clicked when its available to do so
  157. local flingvel = v3(16000,16000,16000) --the rotation velocity that ur character will have while flinging
  158.  
  159. local c=lp.Character
  160. if stopreanimate() or not (c and c:IsDescendantOf(ws)) then return end
  161.  
  162. local hum=c:FindFirstChildOfClass("Humanoid")
  163. local rootpart=gp(c,"HumanoidRootPart","BasePart") or gp(c,"Torso","BasePart") or gp(c,"UpperTorso","BasePart") or (hum and hum.RootPart) or timegp(c,"HumanoidRootPart","BasePart",0.5) or c:FindFirstChildWhichIsA("BasePart")
  164. if not rootpart then return end
  165.  
  166. R15toR6=R15toR6 and hum and (hum.RigType==e.HumanoidRigType.R15)
  167. simrad = (type(simrad)=="number") and (type(shp)=="function") and simrad
  168.  
  169. local flingparts={}
  170. local cam=nil
  171. --theres a way to have ws.currentcamera nil on heartbeat and still have the game run normally
  172. local function refcam()
  173. cam=ws.CurrentCamera
  174. while not cam do
  175. ws:GetPropertyChangedSignal("CurrentCamera"):Wait()
  176. cam=ws.CurrentCamera
  177. end
  178. end
  179. refcam()
  180. local camcf=cam.CFrame
  181. local enumCamS=e.CameraType.Scriptable
  182. local camt=cam.CameraType
  183. local camcon0=nil
  184. local camcon1=nil
  185. local function onnewcamera()
  186. refcam()
  187. if camcon0 then
  188. camcon0:Disconnect()
  189. camcon0=nil
  190. end
  191. if not c then
  192. if cam.CameraType==enumCamS then
  193. cam.CameraType=camt
  194. end
  195. return camcon1:Disconnect()
  196. end
  197. camcon0=cam.Changed:Connect(function(p)
  198. if not c then
  199. camcon0:Disconnect()
  200. return camcon1:Disconnect()
  201. end
  202. if (p=="CFrame") and (cam.CFrame~=camcf) then
  203. cam.CFrame=camcf
  204. elseif (p=="CameraSubject") or (p=="CameraType") then
  205. local subj=cam.CameraSubject
  206. if subj and subj:IsA("Humanoid") and (subj.Parent==c) and (cam.CameraType~=enumCamS) then
  207. cam.CameraType = enumCamS
  208. end
  209. end
  210. end)
  211. local subj=cam.CameraSubject
  212. if subj and subj:IsA("Humanoid") and (subj.Parent==c) and (cam.CameraType~=enumCamS) then
  213. cam.CameraType=enumCamS
  214. end
  215. cam.CFrame=camcf
  216. end
  217. camcon1=ws:GetPropertyChangedSignal("CurrentCamera"):Connect(onnewcamera)
  218. onnewcamera()
  219.  
  220. local fpdh=ws.FallenPartsDestroyHeight
  221. novoid=novoid and (fpdh+1)
  222.  
  223. local function getMeshOfPart(v)
  224. if typeof(v)=="Instance" then
  225. if v:IsA("MeshPart") then
  226. return v.MeshId, v.TextureID
  227. else
  228. v=v:FindFirstChildOfClass("SpecialMesh")
  229. if v then
  230. return v.MeshId, v.TextureId
  231. end
  232. end
  233. end
  234. return nil, nil
  235. end
  236.  
  237. local joints={}
  238. local cframes={}
  239. local des=c:GetDescendants()
  240. for i=1,#des do
  241. local v=des[i]
  242. if v:IsA("JointInstance") then
  243. tinsert(joints,{
  244. Name=v.Name,
  245. C0=v.C0,
  246. C1=v.C1,
  247. Part0=v.Part0,
  248. Part1=v.Part1
  249. })
  250. elseif v:IsA("BasePart") then
  251. cframes[v]=v.CFrame
  252. end
  253. end
  254.  
  255. local function makeplaceholder(v)
  256. if typeof(v)~="Instance" then
  257. return nil
  258. end
  259. if not v.Archivable then
  260. v.Archivable=true
  261. end
  262. v=v:Clone()
  263. local c=v:GetChildren()
  264. for i=1,#c do
  265. local v=c[i]
  266. if v:IsA("SpecialMesh") then
  267. v.Name=rs()
  268. v:ClearAllChildren()
  269. else
  270. v:Destroy()
  271. end
  272. end
  273. v.Name=rs()
  274. v.Anchored=true
  275. v.CanCollide=false
  276. v.Transparency=0.25
  277. v.Parent=ws
  278. return v
  279. end
  280.  
  281. local function filterInstance(v)
  282. local ins=v
  283. if isClientInstance(v) then
  284. v={CFrame=v.CFrame,Name=v.Name,Anchored=true}
  285. else
  286. local meshid,textureid=getMeshOfPart(v)
  287. if meshid and (meshid~="") and textureid and (textureid~="") then
  288. if placeholders then
  289. v={CFrame=v.CFrame,Name=v.Name,Anchored=true,meshid=meshid,textureid=textureid,placeholder=makeplaceholder(v)}
  290. else
  291. v={CFrame=v.CFrame,Name=v.Name,Anchored=true,meshid=meshid,textureid=textureid}
  292. end
  293. else
  294. v={CFrame=v.CFrame,Name=v.Name,Anchored=true}
  295. end
  296. end
  297. local check=ins~=v
  298. while check do
  299. check=false
  300. for i,v1 in pairs(cframes) do
  301. if i==ins then
  302. cframes[ins]=nil
  303. cframes[v]=v1
  304. check=true
  305. break
  306. end
  307. end
  308. end
  309. for i,v1 in pairs(joints) do
  310. if v1.Part0==ins then
  311. v1.Part0=v
  312. elseif v1.Part1==ins then
  313. v1.Part1=v
  314. end
  315. end
  316. if rootpart==ins then
  317. rootpart=v
  318. end
  319. return v
  320. end
  321. for i,v in pairs(joints) do
  322. v.Part0=filterInstance(v.Part0)
  323. v.Part1=filterInstance(v.Part1)
  324. end
  325.  
  326. local Yvel=0
  327. local cfr=rootpart.CFrame
  328. local pos=cfr.Position
  329. local shiftlock=false
  330. local firstperson=false
  331. local xzvel=v3_0
  332. local v3_0150=v3_010*1.5
  333. local camoff=cf(v3_0,camcf.LookVector)
  334. camoff=camoff-v3_001*(camcf.Position-(pos+v3_0150)).Magnitude
  335.  
  336. local refreshjointsinternal=nil
  337. refreshjointsinternal=function(part,refreshed)
  338. if not part then return end
  339. tinsert(refreshed,part)
  340. for i,v in pairs(joints) do
  341. local part0=v.Part0
  342. local part1=v.Part1
  343. if part1 and (part0==part) then
  344. cframes[part1]=cframes[part]*v.C0*v.C1:Inverse()
  345. if not tfind(refreshed,part1) then
  346. refreshjointsinternal(part1,refreshed)
  347. end
  348. elseif part0 and (part1==part) then
  349. cframes[part0]=cframes[part]*v.C1*v.C0:Inverse()
  350. if not tfind(refreshed,part0) then
  351. refreshjointsinternal(part0,refreshed)
  352. end
  353. end
  354. end
  355. end
  356. local function refreshjoints(v)
  357. refreshjointsinternal(v,{})
  358. end
  359.  
  360. if R15toR6 then
  361. local R6parts={
  362. head={Name="Head",Anchored=true},
  363. torso={Name="Torso",Anchored=true},
  364. root={Name="HumanoidRootPart",Anchored=true},
  365. leftArm={Name="Left Arm",Anchored=true},
  366. rightArm={Name="Right Arm",Anchored=true},
  367. leftLeg={Name="Left Leg",Anchored=true},
  368. rightLeg={Name="Right Leg",Anchored=true}
  369. }
  370. for i,v in pairs(R6parts) do
  371. cframes[v]=cfr
  372. end
  373. tinsert(joints,{
  374. Name="Neck",
  375. Part0=R6parts.torso,Part1=R6parts.head,
  376. C0=cf(0,1,0,-1,0,0,0,0,1,0,1,-0),
  377. C1=cf(0,-0.5,0,-1,0,0,0,0,1,0,1,-0)
  378. })
  379. tinsert(joints,{
  380. Name="RootJoint",
  381. Part0=R6parts.root,Part1=R6parts.torso,
  382. C0=cf(0,0,0,-1,0,0,0,0,1,0,1,-0),
  383. C1=cf(0,0,0,-1,0,0,0,0,1,0,1,-0)
  384. })
  385. tinsert(joints,{
  386. Name="Right Shoulder",
  387. Part0=R6parts.torso,Part1=R6parts.rightArm,
  388. C0=cf(1,0.5,0,0,0,1,0,1,-0,-1,0,0),
  389. C1=cf(-0.5,0.5,0,0,0,1,0,1,-0,-1,0,0)
  390. })
  391. tinsert(joints,{
  392. Name="Left Shoulder",
  393. Part0=R6parts.torso,Part1=R6parts.leftArm,
  394. C0=cf(-1,0.5,0,0,0,-1,0,1,0,1,0,0),
  395. C1=cf(0.5,0.5,0,0,0,-1,0,1,0,1,0,0)
  396. })
  397. tinsert(joints,{
  398. Name="Right Hip",
  399. Part0=R6parts.torso,Part1=R6parts.rightLeg,
  400. C0=cf(1,-1,0,0,0,1,0,1,-0,-1,0,0),
  401. C1=cf(0.5,1,0,0,0,1,0,1,-0,-1,0,0)
  402. })
  403. tinsert(joints,{
  404. Name="Left Hip" ,
  405. Part0=R6parts.torso,Part1=R6parts.leftLeg,
  406. C0=cf(-1,-1,0,0,0,-1,0,1,0,1,0,0),
  407. C1=cf(-0.5,1,0,0,0,-1,0,1,0,1,0,0)
  408. })
  409. tinsert(joints,{
  410. Part0=R6parts.root,Part1=rootpart,
  411. C0=cf_0,C1=cf_0
  412. })
  413. refreshjoints(rootpart)
  414. local function getpart(n)
  415. for i,_ in pairs(cframes) do
  416. if (i.Name==n) and (type(i)~="table") then
  417. return i
  418. end
  419. end
  420. return nil
  421. end
  422. local function makejoint(p0, p1, p2)
  423. p1=getpart(p1)
  424. p2=getpart(p2)
  425. if not (p1 and p2) then return end
  426. for i,v in pairs(joints) do
  427. if (v.Part0==p1) and (v.Part1==p2) then
  428. joints[i]=nil
  429. elseif (v.Part0==p2) and (v.Part1==p1) then
  430. joints[i]=nil
  431. end
  432. end
  433. tinsert(joints,{
  434. Part0=p0,Part1=p1,
  435. C0=cf_0,
  436. C1=cframes[p1]:Inverse()*cframes[p0]
  437. })
  438. end
  439. makejoint(R6parts.head,"Head","UpperTorso")
  440. makejoint(R6parts.leftArm,"LeftUpperArm","UpperTorso")
  441. makejoint(R6parts.rightArm,"RightUpperArm","UpperTorso")
  442. makejoint(R6parts.leftLeg,"LeftUpperLeg","LowerTorso")
  443. makejoint(R6parts.rightLeg,"RightUpperLeg","LowerTorso")
  444. makejoint(R6parts.torso,"LowerTorso","HumanoidRootPart")
  445. end
  446.  
  447. local function getPart(name,blacklist)
  448. for i,v in pairs(cframes) do
  449. if (i.Name==name) and not (blacklist and tfind(blacklist,i)) then
  450. return i
  451. end
  452. end
  453. return nil
  454. end
  455.  
  456. local function getPartFromMesh(meshid,textureid,blacklist)
  457. for v,_ in pairs(cframes) do
  458. if (type(v)=="table") and not (blacklist and tfind(blacklist,v)) then
  459. if v.meshid and sfind(v.meshid,meshid) and sfind(v.textureid,textureid) then
  460. return v
  461. end
  462. end
  463. end
  464. return nil
  465. end
  466.  
  467. local function getJoint(name)
  468. for i,v in pairs(joints) do
  469. if v.Name==name then
  470. return v
  471. end
  472. end
  473. return {C0=cf_0,C1=cf_0}
  474. end
  475.  
  476. local function getPartJoint(handle)
  477. for i,v in pairs(joints) do
  478. if v.Part0==handle then
  479. return v
  480. end
  481. end
  482. for i,v in pairs(joints) do
  483. if v.Part1==handle then
  484. return v
  485. end
  486. end
  487. return nil
  488. end
  489.  
  490. local accessorylimbs={
  491. -- paid aligning --
  492. {meshid="12344207333",textureid="12344207341",C0=angles(115,0,0),Name="Left Arm"}, -- Moving Left Arm [White]
  493. {meshid="12344206657",textureid="12344206675",C0=angles(115,0,0),Name="Right Arm"}, -- Moving Right Arm [White]
  494. {meshid="14255522247",textureid="14255543546",C0=angles(0,0,1.5707963267948966),Name="Left Leg"}, -- Blocky Left Leg [White]
  495. {meshid="14255522247",textureid="14255543546",C0=angles(0,0,1.5707963267948966),Name="Right Leg"}, -- Blocky Right Leg [White]
  496. {meshid="14241018198",textureid="14251599953",C0=cf_0,Name="Torso"}, -- Torso Extension
  497. {meshid="11159370334",textureid="11159284657",C0=angles(0,0,1.5707963267948966),Name="Right Leg"}, -- Dummy Head1
  498. {meshid="11263221350",textureid="11263219250",C0=angles(0,0,1.5707963267948966),Name="Left Leg"}, -- Dummy Head2
  499.  
  500. -- free aligning --
  501. {meshid="8761442057",textureid="8761547598",C0=angles(115,0,0),Name="Left Arm"}, -- Yoga Mat1
  502. {meshid="8761442057",textureid="8761421987",C0=angles(115,0,0),Name="Right Arm"}, -- Yoga Mat2
  503. {meshid="9867442567",textureid="9867451480",C0=angles(0,0,-15),Name="Left Leg"}, -- Rouge Bag1
  504. {meshid="9867442661",textureid="9867451480",C0=angles(0,0,-15),Name="Right Leg"}, -- Rouge Bag2
  505. {meshid="4819720316",textureid="4819722776",C0=angles(0,0,-105),Name="Torso"}, -- Robox
  506.  
  507. -- free aligning, fedoras --
  508. {meshid="3030546036",textureid="3033903209",C0=angles(115,0,0),Name="Left Arm"},
  509. {meshid="3030546036",textureid="3360978739",C0=angles(115,0,0),Name="Right Arm"},
  510. {meshid="3030546036",textureid="3409604993",C0=angles(115,-115,0),Name="Left Leg"},
  511. {meshid="3030546036",textureid="3033898741",C0=angles(115,115,0),Name="Right Leg"}
  512. }
  513.  
  514. local alignblacklist={}
  515. for i=1,#accessorylimbs do
  516. local v=accessorylimbs[i]
  517. local p=getPart(v.Name)
  518. local h=getPartFromMesh(v.meshid,v.textureid,alignblacklist)
  519. local w=getPartJoint(h)
  520. if p and w then
  521. w.C0=v.C0
  522. w.Part0=h
  523. w.C1=cf_0
  524. w.Part1=p
  525. tinsert(alignblacklist,h)
  526. end
  527. end
  528.  
  529. local raycastparams=RaycastParams.new()
  530. raycastparams.FilterType=e.RaycastFilterType.Blacklist
  531. raycastparams.RespectCanCollide=true
  532. local rayfilter={}
  533. local characters={}
  534. local function refreshrayfilter()
  535. tclear(rayfilter)
  536. for i,v in pairs(characters) do
  537. tinsert(rayfilter,v)
  538. end
  539. raycastparams.FilterDescendantsInstances=rayfilter
  540. end
  541. local flingtarget=nil
  542. local cframes1={}
  543. local lastpositions={}
  544. local rootparts={}
  545. local function onplayer(v)
  546. local lastc=nil
  547. local function oncharacter()
  548. local newc=v.Character
  549. if newc and (newc ~= lastc) then
  550. lastc=newc
  551. characters[v]=newc
  552. refreshrayfilter()
  553. local hrp=loopgp(newc,"HumanoidRootPart","BasePart")
  554. if v~=lp then
  555. rootparts[v]=hrp
  556. end
  557. twait()
  558. if c and (v==lp) and hrp and (hrp.Parent==newc) and newc:IsDescendantOf(ws) then
  559. local startpos=pos+v3(mrandom(-32,32),0,mrandom(-32,32))
  560. local dir=nil
  561. local poscheck=true
  562. while poscheck do
  563. poscheck=false
  564. for i,v in pairs(rootparts) do
  565. local diff=(startpos-v.Position)*v3_101
  566. if diff.Magnitude<10 then
  567. poscheck=true
  568. dir=dir or diff.Unit
  569. startpos=startpos+dir
  570. end
  571. end
  572. local diff=(startpos-pos)*v3_101
  573. if diff.Magnitude<10 then
  574. poscheck=true
  575. dir=dir or diff.Unit
  576. startpos=startpos+dir
  577. end
  578. end
  579. startpos=cfr+startpos-cfr.Position
  580. if flingtarget then
  581. local con=heartbeat:Connect(function()
  582. local idleoff=v3(sin((sine-0.0375)*16),sin(sine*16),sin((sine+0.075)*16))
  583.  
  584. hrp.CFrame=flingtarget.CFrame+flingtarget.Velocity*(sin(sine*15)+1)+v3(0,-2,0)+idleoff*0.001
  585. hrp.Velocity=idleoff
  586. hrp.RotVelocity=flingvel+idleoff
  587. end)
  588. twait(0.5)
  589. con:Disconnect()
  590. flingtarget=nil
  591. end
  592. tspawn(function()
  593. local con=heartbeat:Connect(function()
  594. hrp.CFrame=startpos+v3(sin((sine-0.0375)*16),sin(sine*16),sin((sine+0.075)*16))*0.005
  595. hrp.Velocity=v3_0
  596. hrp.RotVelocity=v3_0
  597. end)
  598. twait(0.3)
  599. con:Disconnect()
  600. if newc:IsDescendantOf(ws) then
  601. tclear(cframes1)
  602. tclear(lastpositions)
  603. newc:BreakJoints()
  604. twait(0.1)
  605. local cd=newc:GetDescendants()
  606. for i,v in pairs(cframes) do
  607. if type(i)=="table" then
  608. local meshid=i.meshid
  609. if meshid then
  610. local textureid=i.textureid
  611. for i1=1,#cd do
  612. local v=cd[i1]
  613. if v and v:IsA("BasePart") then
  614. local meshid1,textureid1=getMeshOfPart(v)
  615. if (meshid1==meshid) and (textureid1==textureid) then
  616. cd[i1]=nil
  617. cframes1[v]=i
  618. lastpositions[v]=v.Position
  619. break
  620. end
  621. end
  622. end
  623. end
  624. end
  625. end
  626. end
  627. end)
  628. end
  629. end
  630. end
  631. v:GetPropertyChangedSignal("Character"):Connect(oncharacter)
  632. oncharacter()
  633. end
  634. local plrst=plrs:GetPlayers()
  635. for i=1,#plrst do onplayer(plrst[i]) end
  636. plrs.PlayerAdded:Connect(onplayer)
  637. plrs.PlayerRemoving:Connect(function(v)
  638. characters[v]=nil
  639. rootparts[v]=nil
  640. end)
  641.  
  642. local mradN05=rad(-0.5)
  643. local enumMLC=e.MouseBehavior.LockCenter
  644. local enumMB2=e.UserInputType.MouseButton2
  645. local enumMLCP=e.MouseBehavior.LockCurrentPosition
  646. local enumMD=e.MouseBehavior.Default
  647. local enumMW=e.UserInputType.MouseWheel
  648.  
  649. local mode="default"
  650. local modes={default={}}
  651. local function addmode(key,mode)
  652. if (type(key)~="string") or (type(mode)~="table") then
  653. return
  654. end
  655. for i, v in pairs(mode) do
  656. if type(v)~="function" then
  657. mode[i]=nil
  658. end
  659. end
  660. if key=="default" then
  661. modes.default=mode
  662. if mode.modeEntered then
  663. mode.modeEntered()
  664. end
  665. elseif #key==1 then
  666. key=e.KeyCode[supper(ssub(key,1,1))]
  667. modes[key]=mode
  668. end
  669. end
  670.  
  671. local keyW=e.KeyCode.W
  672. local keyA=e.KeyCode.A
  673. local keyS=e.KeyCode.S
  674. local keyD=e.KeyCode.D
  675. local keySpace=e.KeyCode.Space
  676. local keyShift=e.KeyCode.LeftShift
  677. local movementkeys = {
  678. [keyW]=false,
  679. [keyA]=false,
  680. [keyS]=false,
  681. [keyD]=false,
  682. [keySpace]=false
  683. }
  684. uis.InputBegan:Connect(function(a)
  685. if gs.MenuIsOpen or uis:GetFocusedTextBox() then
  686. return
  687. end
  688. a=a.KeyCode
  689. if movementkeys[a]==false then
  690. movementkeys[a]=true
  691. elseif a==keyShift then
  692. shiftlock=allowshiftlock and not shiftlock
  693. elseif modes[a] then
  694. if modes[mode].modeLeft then
  695. modes[mode].modeLeft()
  696. end
  697. if mode==a then
  698. mode="default"
  699. else
  700. mode=a
  701. end
  702. if modes[mode].modeEntered then
  703. modes[mode].modeEntered()
  704. end
  705. end
  706. end)
  707. uis.InputEnded:Connect(function(a)
  708. if movementkeys[a.KeyCode] then
  709. movementkeys[a.KeyCode]=false
  710. end
  711. end)
  712. uis.InputChanged:Connect(function(a,b)
  713. if (not b) and (a.UserInputType==enumMW) then
  714. camoff=camoff+a.Position*v3_001*(0.75-camoff.Z/4)
  715. if camoff.Z>0 then
  716. camoff=camoff-camoff.Position
  717. end
  718. firstperson=camoff.Z==0
  719. end
  720. end)
  721.  
  722. local function fling(target,duration,rotVelocity)
  723. twait()
  724. return true --maybe later
  725. end
  726.  
  727. local function predictionfling(target)
  728. if typeof(target)~="Instance" then
  729. target=mouse.Target
  730. if not target then
  731. return twait() and false
  732. end
  733. end
  734. if target:IsA("Humanoid") or target:IsA("BasePart") then
  735. target=target.Parent
  736. if target:IsA("Accessory") then
  737. target=target.Parent
  738. end
  739. end
  740. if (not target:IsA("Model")) or (target==c) then
  741. return twait() and false
  742. end
  743. target=gp(target,"HumanoidRootPart","BasePart") or gp(target,"Torso","BasePart") or gp(target,"UpperTorso","BasePart")
  744. if not (target and target:IsDescendantOf(ws)) then
  745. return twait() and false
  746. end
  747. flingtarget=target
  748. twait()
  749. return true
  750. end
  751.  
  752. if ctrlclicktp then
  753. ctrlclicktp=e.KeyCode.LeftControl
  754. local tpoff=v3_010*3
  755. if clickfling then
  756. mouse.Button1Down:Connect(function()
  757. if mouse.Target then
  758. if uis:IsKeyDown(ctrlclicktp) then
  759. pos=mouse.Hit.Position+tpoff
  760. cfr=cf(pos,pos+camoff.LookVector*v3_101)
  761. xzvel=v3_0
  762. Yvel=0
  763. else
  764. predictionfling()
  765. end
  766. end
  767. end)
  768. else
  769. mouse.Button1Down:Connect(function()
  770. if mouse.Target and uis:IsKeyDown(ctrlclicktp) then
  771. pos=mouse.Hit.Position+tpoff
  772. cfr=cf(pos,pos+camoff.LookVector*v3_101)
  773. xzvel=v3_0
  774. Yvel=0
  775. end
  776. end)
  777. end
  778. elseif clickfling then
  779. mouse.Button1Down:Connect(predictionfling)
  780. end
  781.  
  782. local noYvelTime=1
  783. local lastsine=sine
  784. local pose=nil
  785. local con=nil
  786. local function mainFunction()
  787. if not c then
  788. for i,v in pairs(cframes) do
  789. local p=i.placeholder
  790. if p then
  791. p:Destroy()
  792. end
  793. end
  794. uis.MouseBehavior=enumMD
  795. onnewcamera()
  796. local c=lp.Character
  797. if c then
  798. cam.CameraSubject=c:FindFirstChildOfClass("Humanoid")
  799. end
  800. return con and con:Disconnect()
  801. end
  802.  
  803. sine=osclock()
  804. local delta=sine-lastsine
  805. deltaTime=clamp(delta*10,0,1)
  806. lastsine=sine
  807.  
  808. if shiftlock then
  809. if allowshiftlock then
  810. uis.MouseBehavior=enumMLC
  811. local rotation=uis:GetMouseDelta()*mradN05
  812. local camoffpos=camoff.Position
  813. camoff=cf(camoffpos,camoffpos+camoff.LookVector)*angles(rotation.Y,rotation.X,0)
  814. else
  815. shiftlock=false
  816. end
  817. elseif firstperson then
  818. uis.MouseBehavior=enumMLC
  819. local rotation=uis:GetMouseDelta()*mradN05
  820. local camoffpos=camoff.Position
  821. camoff=cf(camoffpos,camoffpos+camoff.LookVector)*angles(rotation.Y,rotation.X,0)
  822. elseif uis:IsMouseButtonPressed(enumMB2) then
  823. uis.MouseBehavior=enumMLCP
  824. local rotation=uis:GetMouseDelta()*mradN05
  825. local camoffpos=camoff.Position
  826. camoff=cf(camoffpos,camoffpos+camoff.LookVector)*angles(rotation.Y,rotation.X,0)
  827. else
  828. uis.MouseBehavior=enumMD
  829. end
  830.  
  831. local raycastresult=ws:Raycast(pos,v3_010*(fpdh-pos.Y),raycastparams)
  832. local onground=nil
  833. if raycastresult then
  834. raycastresult=raycastresult.Position
  835. onground=(pos.Y-raycastresult.Y)<3.01
  836. if onground then
  837. Yvel=0
  838. cfr=cfr+v3_010*(raycastresult.Y+3-pos.Y)*clamp(delta*20,0,1)
  839. if movementkeys[keySpace] then
  840. Yvel=jumpPower
  841. end
  842. else
  843. Yvel=Yvel-gravity*delta
  844. if pos.Y+Yvel*delta<raycastresult.Y then
  845. Yvel=0
  846. cfr=cfr+v3_010*(raycastresult.Y+3-pos.Y)
  847. end
  848. end
  849. else
  850. Yvel=0
  851. onground=false
  852. end
  853. xzvel=v3_0
  854. if movementkeys[keyW] then
  855. xzvel=xzvel+(camoff.LookVector*v3_101).Unit
  856. end
  857. if movementkeys[keyS] then
  858. xzvel=xzvel-(camoff.LookVector*v3_101).Unit
  859. end
  860. if movementkeys[keyA] then
  861. xzvel=xzvel-(camoff.RightVector*v3_101).Unit
  862. end
  863. if movementkeys[keyD] then
  864. xzvel=xzvel+(camoff.RightVector*v3_101).Unit
  865. end
  866. pos=cfr.Position
  867. if shiftlock or firstperson then
  868. if xzvel.Magnitude>0 then
  869. xzvel=xzvel.Unit*walkSpeed
  870. end
  871. cfr=cf(pos,pos+camoff.LookVector*v3_101)
  872. elseif xzvel.Magnitude>0 then
  873. xzvel=xzvel.Unit*walkSpeed
  874. cfr=cfr:Lerp(cf(pos,pos+xzvel),deltaTime)
  875. end
  876. cfr=cfr+(xzvel+(v3_010*Yvel))*delta
  877. pos=cfr.Position
  878.  
  879. camcf=cf(pos,pos+camoff.LookVector)+camoff.LookVector*camoff.Z+v3_0150
  880. if shiftlock and not firstperson then
  881. camcf=camcf+camcf.RightVector*1.75
  882. end
  883. if cam then
  884. cam.CFrame=camcf
  885. end
  886.  
  887. if onground then
  888. if xzvel==v3_0 then
  889. pose="idle"
  890. else
  891. pose="walk"
  892. end
  893. elseif Yvel>0 then
  894. pose="jump"
  895. else
  896. pose="fall"
  897. end
  898. local lerpfunc=modes[mode][pose]
  899. lerpfunc=lerpfunc or modes.default[pose]
  900. if lerpfunc then
  901. lerpfunc()
  902. end
  903.  
  904. cframes[rootpart]=cfr
  905. refreshjoints(rootpart)
  906.  
  907. if abs(Yvel)>1 then
  908. noYvelTime=0
  909. else
  910. noYvelTime=clamp(noYvelTime+delta*0.3,0,1)
  911. xzvel=xzvel*(1-noYvelTime)
  912. end
  913.  
  914. local idlerv=v3(sin((sine-0.0375)*16),sin(sine*16),sin((sine+0.075)*16))
  915. local idleoff=idlerv*0.001
  916.  
  917. for i,v in pairs(cframes) do
  918. local p=i.placeholder
  919. if p then
  920. if p.Parent~=ws then
  921. p.Parent=ws
  922. end
  923. p.CFrame=v
  924. end
  925. end
  926. for i,v in pairs(cframes1) do
  927. if (not i.Anchored) and i:IsDescendantOf(ws) then
  928. if i.ReceiveAge==0 then
  929. local p=v.placeholder
  930. if p and p.Parent then
  931. p.Parent=nil
  932. end
  933. v=cframes[v]
  934. local lastpos=lastpositions[i]
  935. local vel=(v.Position-lastpos)/delta
  936. if vel.Magnitude>speedlimit then
  937. vel=vel.Unit*speedlimit
  938. v=v+(lastpos+vel*delta)-v.Position
  939. end
  940. lastpositions[i]=v.Position
  941. if vel.Magnitude<0.15 then
  942. v=v+idleoff
  943. end
  944. if novoid and (v.Y<novoid) then
  945. v=v+v3_010*(novoid-v.Y)
  946. end
  947. i.Velocity=getNetlessVelocity(vel*noYvelTime+xzvel)
  948. i.CFrame=v
  949. i.RotVelocity=idlerv
  950. else
  951. lastpositions[i]=i.Position
  952. end
  953. end
  954. end
  955.  
  956. if simrad then
  957. shp(lp,"SimulationRadius",simrad)
  958. end
  959. end
  960.  
  961. con=heartbeat:Connect(mainFunction)
  962. mainFunction()
  963.  
  964. stopreanimate=function()
  965. if c then
  966. c=nil
  967. return true
  968. else
  969. return false
  970. end
  971. end
  972.  
  973. local legcfR=cf(1,-1,0)
  974. local legcfL=cf(-1,-1,0)
  975. local raydir=v3_010*-2
  976. local function raycastlegs() --this returns 2 values: right leg raycast offset, left leg raycast offset
  977. local rY=ws:Raycast((cfr*legcfR).Position,raydir,raycastparams)
  978. local lY=ws:Raycast((cfr*legcfL).Position,raydir,raycastparams)
  979. return rY and (rY.Position.Y-(pos.Y-3)) or 0,lY and (lY.Position.Y-(pos.Y-3)) or 0
  980. end
  981.  
  982. local function velbycfrvec() --this returns 2 values: forward/backwards movement (from -1 to 1), right/left movement (from -1 to 1)
  983. local fw=cfr.LookVector*xzvel/walkSpeed
  984. local rt=cfr.RightVector*xzvel/walkSpeed
  985. return fw.X+fw.Z,rt.X+rt.Z
  986. end
  987.  
  988. local lastvel=v3_0
  989. local velchg1=v3_0
  990. local function velchgbycfrvec() --this returns 2 values: forward/backwards velocity change, right/left velocity change
  991. velchg1=velchg1+(lastvel-xzvel) --i recommend setting velchg1 to v3_0 when u start using this function or it will look worse
  992. lastvel=xzvel
  993. velchg1=velchg1:Lerp(v3_0,deltaTime/2)
  994. local fw=cfr.LookVector*velchg1/32
  995. local rt=cfr.RightVector*velchg1/32
  996. return fw.X+fw.Z,rt.X+rt.Z
  997. end
  998.  
  999. local function rotToMouse(alpha) --this rotates ur character towards your mouse hit position
  1000. local mpos=mouse.Hit.Position
  1001. cfr=cfr:Lerp(cf(pos,v3(mpos.X,pos.Y,mpos.Z)),alpha or deltaTime)
  1002. end
  1003.  
  1004. local function setWalkSpeed(n)
  1005. if type(n) ~= "number" then
  1006. n=16
  1007. end
  1008. walkSpeed=n
  1009. end
  1010. local function setJumpPower(n)
  1011. if type(n) ~= "number" then
  1012. n=50
  1013. end
  1014. jumpPower=n
  1015. end
  1016. local function setGravity(n)
  1017. if type(n) ~= "number" then
  1018. n=196.2
  1019. end
  1020. gravity=n
  1021. end
  1022.  
  1023. return {
  1024. cframes=cframes,
  1025. joints=joints,
  1026. refreshjoints=refreshjoints,
  1027. raycastlegs=raycastlegs,
  1028. velbycfrvec=velbycfrvec,
  1029. velchgbycfrvec=velchgbycfrvec,
  1030. addmode=addmode,
  1031. getPart=getPart,
  1032. getPartFromMesh=getPartFromMesh,
  1033. getJoint=getJoint,
  1034. getPartJoint=getPartJoint,
  1035. rotToMouse=rotToMouse,
  1036. setWalkSpeed=setWalkSpeed,
  1037. setJumpPower=setJumpPower,
  1038. setGravity=setGravity
  1039. }
  1040. end
  1041.  
  1042. local t=reanimate()
  1043. if type(t)~="table" then return end
  1044. local raycastlegs=t.raycastlegs
  1045. local velbycfrvec=t.velbycfrvec
  1046. local velchgbycfrvec=t.velchgbycfrvec
  1047. local addmode=t.addmode
  1048. local getJoint=t.getJoint
  1049. local RootJoint=getJoint("RootJoint")
  1050. local RightShoulder=getJoint("Right Shoulder")
  1051. local LeftShoulder=getJoint("Left Shoulder")
  1052. local RightHip=getJoint("Right Hip")
  1053. local LeftHip=getJoint("Left Hip")
  1054. local Neck=getJoint("Neck")
  1055. addmode("default", {
  1056. idle = function()
  1057. local rY, lY = raycastlegs()
  1058. local Cfw, Crt = velchgbycfrvec()
  1059. LeftShoulder.C0=LeftShoulder.C0:Lerp(cf(-1,1+0.4*sin(sine*1),0)*angles(-0.15707963267948966+0.06981317007977318*sin((sine+9)*40),-1.5707963267948966,0),deltaTime) LeftHip.C0=LeftHip.C0:Lerp(cf(-1,-1+0.3*sin(sine*1),0)*angles(0,-0.15707963267948966,0),deltaTime) RightShoulder.C0=RightShoulder.C0:Lerp(cf(1,0.2,0)*angles(-1.5707963267948966+0.15707963267948966*sin((sine+2)*1),1.5707963267948966,0),deltaTime) RightHip.C0=RightHip.C0:Lerp(cf(1,-1+0.3*sin(sine*1),0)*angles(-1.5707963267948966,1.5707963267948966,0),deltaTime) RootJoint.C0=RootJoint.C0:Lerp(cf(5+4*sin((sine + 0.3)*0.2),4,0)*angles(0.03490658503988659,0,3.141592653589793),deltaTime)
  1060. end,
  1061.  
  1062. walk = function()
  1063. local Vfw, Vrt = velbycfrvec()
  1064. local rY, lY = raycastlegs()
  1065. local Cfw, Crt = velchgbycfrvec()
  1066. LeftHip.C0=LeftHip.C0:Lerp(cf(-1,0.2 * sin(sine*1),0)*angles(0.3490658503988659,-1.5707963267948966,0),deltaTime) RightHip.C0=RightHip.C0:Lerp(cf(1,-1,0)*angles(-0.3490658503988659,1.5707963267948966,0),deltaTime) LeftShoulder.C0=LeftShoulder.C0:Lerp(cf(-1.5,0,0)*angles(-0.20943951023931956+0.15707963267948966*sin(sine*1),0,0),deltaTime) RightShoulder.C0=RightShoulder.C0:Lerp(cf(1,0.9+0.8*sin(sine*1),0)*angles(-0.20943951023931956+0.08726646259971647*sin(sine*1),1.5707963267948966,0),deltaTime) Neck.C0=Neck.C0:Lerp(cf(0,1,0)*angles(-1.5707963267948966,0,3.141592653589793),deltaTime) RootJoint.C0=RootJoint.C0:Lerp(cf(2+3*sin((sine + 2)*0.2),2+0.7*sin((sine + 4)*1),0)*angles(3.490658503988659,0,3.141592653589793),deltaTime)
  1067. end,
  1068.  
  1069. jump = function()
  1070. local Cfw, Crt = velchgbycfrvec()
  1071. local Vfw, Vrt = velbycfrvec() LeftShoulder.C0=LeftShoulder.C0:Lerp(cf(-1,1+0.4*sin(sine*1),0)*angles(-0.15707963267948966+0.06981317007977318*sin((sine+9)*40),-1.5707963267948966,0),deltaTime) LeftHip.C0=LeftHip.C0:Lerp(cf(-1,-1+0.3*sin(sine*1),0)*angles(0,-0.15707963267948966,0),deltaTime) RightShoulder.C0=RightShoulder.C0:Lerp(cf(1,0.2,0)*angles(-1.5707963267948966+0.15707963267948966*sin((sine+2)*1),1.5707963267948966,0),deltaTime) Neck.C0=Neck.C0:Lerp(cf(0,1,0)*angles(-1.5707963267948966,0,3.141592653589793),deltaTime) RightHip.C0=RightHip.C0:Lerp(cf(1,-1+0.3*sin(sine*1),0)*angles(-1.5707963267948966,1.5707963267948966,0),deltaTime) RootJoint.C0=RootJoint.C0:Lerp(cf(5+4*sin((sine + 0.3)*0.2),4,0)*angles(0.03490658503988659,0,3.141592653589793),deltaTime)
  1072. end,
  1073.  
  1074. fall = function()
  1075. local Vfw, Vrt = velbycfrvec()
  1076. local Cfw, Crt = velchgbycfrvec()
  1077. LeftShoulder.C0=LeftShoulder.C0:Lerp(cf(-1,1+0.4*sin(sine*1),0)*angles(-0.15707963267948966+0.06981317007977318*sin((sine+9)*40),-1.5707963267948966,0),deltaTime) LeftHip.C0=LeftHip.C0:Lerp(cf(-1,-1+0.3*sin(sine*1),0)*angles(0,-0.15707963267948966,0),deltaTime) RightShoulder.C0=RightShoulder.C0:Lerp(cf(1,0.2,0)*angles(-1.5707963267948966+0.15707963267948966*sin((sine+2)*1),1.5707963267948966,0),deltaTime) RightHip.C0=RightHip.C0:Lerp(cf(1,-1+0.3*sin(sine*1),0)*angles(-1.5707963267948966,1.5707963267948966,0),deltaTime) RootJoint.C0=RootJoint.C0:Lerp(cf(5+4*sin((sine + 0.3)*0.2),4,0)*angles(0.03490658503988659,0,3.141592653589793),deltaTime)
  1078. end
  1079. })
  1080.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement