Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This script is for synapse x/non luau supported executors
- --]]
- -- services
- local players = game:GetService("Players")
- local runService = game:GetService("RunService")
- local inputService = game:GetService("UserInputService")
- -- objects
- local player = players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid, rootPart
- local camera = workspace.CurrentCamera
- -- variables
- local rootPartCFrame
- local flyObj = {
- enabled = false,
- keyInput = Enum.KeyCode.F1,
- flySpeed = .9,
- qeFly = false,
- _navigation = {
- upward = false,
- downward = false,
- forward = false,
- backward = false,
- rightward = false,
- leftward = false,
- }
- }
- -- functions
- local function onCharacterAdded(newCharacter)
- character = newCharacter
- humanoid, rootPart = character:FindFirstChildWhichIsA("Humanoid"), character:WaitForChild("HumanoidRootPart")
- end
- -- main
- onCharacterAdded(character)
- player.CharacterAdded:Connect(onCharacterAdded)
- inputService.InputBegan:Connect(function(input, gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard and not (inputService:GetFocusedTextBox() and gameProcessedEvent) then
- if input.KeyCode == flyObj.keyInput then
- flyObj.enabled = not flyObj.enabled
- rootPartCFrame = rootPart.CFrame
- end
- end
- end)
- runService.RenderStepped:Connect(function()
- if not inputService:GetFocusedTextBox() and flyObj.enabled then
- flyObj._navigation.upward = (flyObj.qeFly and inputService:IsKeyDown(Enum.KeyCode.Q))
- flyObj._navigation.downward = (flyObj.qeFly and inputService:IsKeyDown(Enum.KeyCode.E))
- flyObj._navigation.forward = inputService:IsKeyDown(Enum.KeyCode.W)
- flyObj._navigation.backward = inputService:IsKeyDown(Enum.KeyCode.S)
- flyObj._navigation.leftward = inputService:IsKeyDown(Enum.KeyCode.A)
- flyObj._navigation.rightward = inputService:IsKeyDown(Enum.KeyCode.D)
- end
- end)
- runService.Heartbeat:Connect(function(deltaTime)
- if flyObj.enabled and (humanoid and rootPart) then
- for _, animObj in ipairs(humanoid:GetPlayingAnimationTracks()) do animObj:Stop(0) end
- local cameraOrientation = CFrame.fromOrientation(camera.CFrame:ToOrientation())
- local calcFront, calcRight, calcTop = (cameraOrientation.LookVector), (cameraOrientation.RightVector), (cameraOrientation.UpVector)
- local pressedDirection do
- pressedDirection = Vector3.zero
- for name, pressed in pairs(flyObj._navigation) do
- if not pressed then
- pressedDirection = pressedDirection + Vector3.zero
- else
- if name == "rightward" then
- pressedDirection = pressedDirection + calcRight
- elseif name == "upward" then
- pressedDirection = pressedDirection + calcTop
- elseif name == "forward" then
- pressedDirection = pressedDirection + calcFront
- elseif name == "leftward" then
- pressedDirection = pressedDirection - calcRight
- elseif name == "downward" then
- pressedDirection = pressedDirection - calcTop
- elseif name == "backward" then
- pressedDirection = pressedDirection - calcFront
- end
- end
- end
- pressedDirection = pressedDirection * ((flyObj.flySpeed / 0.0305) * deltaTime)
- end
- local difference = (rootPartCFrame.Position - rootPart.Position)
- rootPart.Anchored = false
- humanoid:ChangeState(Enum.HumanoidStateType.Climbing)
- character:TranslateBy(pressedDirection)
- rootPart.CFrame = ((CFrame.identity + (rootPart.Position + difference)) * cameraOrientation)
- rootPartCFrame = rootPart.CFrame
- rootPart.AssemblyLinearVelocity, rootPart.AssemblyAngularVelocity = Vector3.zero, Vector3.zero
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment