MaxproGlitcher

Free cam test Béta by Max

Mar 23rd, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. -- Basic Freecam Script
  2. -- You can move faster by holding the click button [setting below ! :) ]
  3. local allowspeedmove = true
  4. wait(1)
  5.  
  6. local c = workspace.CurrentCamera
  7. local player = game.Players.LocalPlayer
  8. local userInput = game:GetService("UserInputService")
  9. local rs = game:GetService("RunService")
  10. local starterPlayer = game:GetService("StarterPlayer")
  11. --local util = LoadLibrary("RbxUtility")
  12. --local camSync = util.CreateSignal()
  13.  
  14. local selected = false
  15. local speed = 60
  16. local lastUpdate = 0
  17.  
  18. local camera = Instance.new('Part', workspace)
  19. camera.CanCollide = false
  20. camera.Anchored = true
  21. camera.Transparency = 1
  22. camera.Name = 'FreeCam'
  23. camera.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0,5,0)
  24. --rs:BindToRenderStep("CamSync",190,function ()
  25. -- camSync:fire()
  26. --end)
  27.  
  28. c.Changed:connect(function (property)
  29. if property == "CoordinateFrame" then
  30. -- camSync:fire()
  31. end
  32. end)
  33.  
  34. function getNextMovement(deltaTime)
  35. local nextMove = Vector3.new()
  36. -- Left/Right
  37. if userInput:IsKeyDown("A") or userInput:IsKeyDown("Left") then
  38. nextMove = nextMove + Vector3.new(-1,0,0)
  39. end
  40. if userInput:IsKeyDown("D") or userInput:IsKeyDown("Right") then
  41. nextMove = nextMove + Vector3.new(1,0,0)
  42. end
  43. -- Forward/Back
  44. if userInput:IsKeyDown("W") or userInput:IsKeyDown("Up") then
  45. nextMove = nextMove + Vector3.new(0,0,-1)
  46. end
  47. if userInput:IsKeyDown("S") or userInput:IsKeyDown("Down") then
  48. nextMove = nextMove + Vector3.new(0,0,1)
  49. end
  50. -- Up/Down
  51. if userInput:IsKeyDown("Space") or userInput:IsKeyDown("Q") then
  52. nextMove = nextMove + Vector3.new(0,1,0)
  53. end
  54. if userInput:IsKeyDown("LeftControl") or userInput:IsKeyDown("E") then
  55. nextMove = nextMove + Vector3.new(0,-1,0)
  56. end
  57. return CFrame.new( nextMove * (speed * deltaTime) )
  58. end
  59.  
  60. function onSelected()
  61. local char = player.Character
  62. if char then
  63. local root = camera
  64. currentPos = root.Position
  65. selected = true
  66. lastUpdate = tick()
  67. c.CameraSubject = root
  68. player.Character.HumanoidRootPart.Anchored = true
  69. while selected do
  70. local delta = tick()-lastUpdate
  71. local look = (c.Focus.p-c.CoordinateFrame.p).unit
  72. local move = getNextMovement(delta)
  73. local pos = root.Position
  74. root.CFrame = CFrame.new(pos,pos+look) * move
  75. lastUpdate = tick()
  76. wait(0.01)
  77. -- camSync:wait()
  78. end
  79. player.Character.HumanoidRootPart.Anchored = false
  80. c.CameraSubject = player.Character.Humanoid
  81. root.Velocity = Vector3.new()
  82. end
  83. end
  84.  
  85. function onDeselected()
  86. selected = false
  87. end
  88.  
  89. local isOn = true
  90. spawn(onSelected)
  91.  
  92. function onKeyPressed(_,state)
  93. if state == Enum.UserInputState.Begin then
  94. isOn = not isOn
  95. if isOn then
  96. onSelected()
  97. else
  98. onDeselected()
  99. end
  100. end
  101. end
  102.  
  103. local mouse = player:GetMouse()
  104. mouse.Button1Down:Connect(function()
  105. if allowspeedmove then speed = 120 end
  106. end)
  107. mouse.Button1Up:Connect(function()
  108. speed = 60
  109. end)
  110.  
  111. function ResetCamera()
  112. camera.Position = player.Character.HumanoidRootPart.Position + Vector3.new(0,5,0)
  113. end
  114.  
  115. game:GetService("ContextActionService"):BindAction("Noclip Toggle",onKeyPressed,false,"r")
  116. game:GetService("ContextActionService"):BindAction("Reset Camera Position",ResetCamera,false,"z")
Add Comment
Please, Sign In to add comment