Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local abilityEnabled = true
- local hrp
- local humanoid
- local function isPlayerCharacter(part)
- local model = part:FindFirstAncestorOfClass("Model")
- if not model then return false end
- return Players:GetPlayerFromCharacter(model) ~= nil
- end
- local function setupCharacter(character)
- hrp = character:WaitForChild("HumanoidRootPart")
- humanoid = character:WaitForChild("Humanoid")
- humanoid.Died:Connect(function()
- abilityEnabled = false
- end)
- end
- if player.Character then
- setupCharacter(player.Character)
- end
- player.CharacterAdded:Connect(setupCharacter)
- RunService.RenderStepped:Connect(function()
- if not abilityEnabled or not hrp or not humanoid then
- return
- end
- local params = RaycastParams.new()
- params.FilterType = Enum.RaycastFilterType.Blacklist
- params.FilterDescendantsInstances = {player.Character}
- local ray = workspace:Raycast(
- hrp.Position,
- hrp.CFrame.LookVector * 3,
- params
- )
- if ray then
- if isPlayerCharacter(ray.Instance) then
- return
- end
- if not ray.Instance.CanCollide then
- return
- end
- local moveDir = humanoid.MoveDirection
- if moveDir.Magnitude > 0.1 then
- hrp.AssemblyLinearVelocity = Vector3.new(
- hrp.AssemblyLinearVelocity.X,
- 18,
- hrp.AssemblyLinearVelocity.Z
- )
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment