You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
screen keeps going black even though the velocity isnt glitched in any way - What is the issue? Include screenshots / videos if possible!
the screen keeps going black, like the camera gets sent really far away for some reason. - What solutions have you tried so far? Did you look for solutions on the Creator Hub?
theres nothing i could realistically try because it doesnt even seem to be an issue with my code? i tried going back to code which worked and it still had the same issue after testing
local ContextActionService = game:GetService("ContextActionService")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local RemoteEvents = game.ReplicatedStorage.RemoteEvents
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local ClientSlideVelocity = Instance.new("LinearVelocity")
ClientSlideVelocity.Name = "MovementVelocity"
ClientSlideVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
ClientSlideVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
ClientSlideVelocity.ForceLimitsEnabled = true
ClientSlideVelocity.MaxAxesForce = Vector3.new(10000, 0, 10000)
ClientSlideVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
ClientSlideVelocity.Attachment0 = HumanoidRootPart.RootAttachment
ClientSlideVelocity.Enabled = false
ClientSlideVelocity.Parent = HumanoidRootPart
local RaycastParameters = RaycastParams.new()
RaycastParameters.RespectCanCollide = true
RaycastParameters.FilterDescendantsInstances = {Character}
local Magnitude = Instance.new("NumberValue")
local UnitVector = Instance.new("Vector3Value")
local SlidingAnimation = Humanoid.Animator:LoadAnimation(game.ReplicatedStorage.Animations.Slide)
local DivingAnimation = Humanoid.Animator:LoadAnimation(game.ReplicatedStorage.Animations.Dive)
local SlidingWithBombAnimation = Humanoid.Animator:LoadAnimation(game.ReplicatedStorage.Animations.SlideWithBomb)
local TweenToZero = TweenService:Create(Magnitude, TweenInfo.new(0.75, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {Value = 0})
local TimeJumped = 0
local TimeAbilityStarted = 0
local MovementDebounce = false
Character:SetAttribute("IsUsingAbility", false)
Character:SetAttribute("LastMovementState", "None")
local PlaySound = game.ReplicatedStorage.RemoteEvents.PlaySound
local EndSound = game.ReplicatedStorage.RemoteEvents.EndSound
function StopMovement()
if Character:FindFirstChild("Timebomb") then
Humanoid.WalkSpeed = 24
else
Humanoid.WalkSpeed = 16
end
Humanoid.JumpPower = 50
Humanoid.HipHeight = 0
ClientSlideVelocity.Enabled = false
SlidingAnimation:Stop(0)
SlidingWithBombAnimation:Stop(0)
Magnitude.Value = 0
DivingAnimation:Stop(0)
ClientSlideVelocity.MaxAxesForce = Vector3.new(10000, 0, 10000)
Character:SetAttribute("IsUsingAbility", false)
EndSound:FireServer("Slide")
EndSound:FireServer("Dive")
end
function UpdateMagnitudeValue()
TweenToZero:Cancel()
Magnitude.Value = math.min(Magnitude.Value * 1.1, 55)
TweenToZero:Play()
end
function F(x)
return -3 - x
end
function Slide(Name, InputState, InputObject)
if InputState ~= Enum.UserInputState.Begin or Humanoid.FloorMaterial == Enum.Material.Air or MovementDebounce then return end
MovementDebounce = true
Character:SetAttribute("IsUsingAbility", true)
UnitVector.Value = Character:GetAttribute("AccurateMoveDirection").Magnitude ~= 0 and Character:GetAttribute("AccurateMoveDirection") or HumanoidRootPart.CFrame.LookVector
Magnitude.Value = 45
ClientSlideVelocity.Enabled = true
TweenToZero:Play()
TimeAbilityStarted = os.clock()
if Character:FindFirstChild("Timebomb") then
ClientSlideVelocity.MaxAxesForce = Vector3.new(50000, 0, 50000)
end
if os.clock() - TimeJumped < 0.3 then
print("1")
Humanoid.HipHeight = -2
PlaySound:FireServer("Dive")
Character:SetAttribute("LastMovementState", "Diving")
DivingAnimation:Play(0)
else
print("2")
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 1
Humanoid.HipHeight = -1
PlaySound:FireServer("Slide")
Character:SetAttribute("LastMovementState", "Sliding")
if Character:FindFirstChild("Timebomb") then
SlidingWithBombAnimation:Play(0)
else
SlidingAnimation:Play(0)
end
end
RemoteEvents.EmitMovementParticles:FireServer(HumanoidRootPart.Position + Vector3.new(0, Humanoid.HipHeight, 0))
while Magnitude.Value > 0 do
task.wait()
end
StopMovement()
task.wait(1.6)
MovementDebounce = false
return Enum.ContextActionResult.Pass
end
-- THIS IS WHAT IS CAUSING ISSUES
function Wallrun(Name, InputState, InputObject)
if Humanoid.FloorMaterial ~= Enum.Material.Air or MovementDebounce then return end
if InputState == Enum.UserInputState.Begin then
local LeftWallRaycast = workspace:Raycast(HumanoidRootPart.Position, HumanoidRootPart.CFrame.RightVector * -5, RaycastParameters)
local RightWallRaycast = workspace:Raycast(HumanoidRootPart.Position, HumanoidRootPart.CFrame.RightVector * 5, RaycastParameters)
local WallNormal = LeftWallRaycast ~= nil and LeftWallRaycast.Normal or RightWallRaycast ~= nil and RightWallRaycast.Normal or nil
if WallNormal then
local BaseDirection = WallNormal:Cross(Vector3.new(0, 1, 0))
local MoveDirection = BaseDirection * math.sign(BaseDirection:Dot(Humanoid.MoveDirection))
HumanoidRootPart.AssemblyLinearVelocity = MoveDirection * 100
else
return Enum.ContextActionResult.Pass
end
MovementDebounce = true
Character:SetAttribute("IsUsingAbility", true)
Character:SetAttribute("LastMovementState", "Wallrunning")
end
return Enum.ContextActionResult.Pass
end
Humanoid.StateChanged:Connect(function(Old, New)
if New == Enum.HumanoidStateType.Jumping then
TimeJumped = os.clock()
end
end)
UserInputService.JumpRequest:Connect(function()
if Character:GetAttribute("IsUsingAbility") == true and os.clock() - TimeAbilityStarted > 0.3 then
StopMovement()
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
if Character:GetAttribute("LastMovementState") == "Diving" then
HumanoidRootPart.AssemblyLinearVelocity += Humanoid.MoveDirection * 20
end
end
end)
Magnitude.Changed:Connect(function()
ClientSlideVelocity.VectorVelocity = UnitVector.Value * Magnitude.Value
end)
UnitVector.Changed:Connect(function()
ClientSlideVelocity.VectorVelocity = UnitVector.Value * Magnitude.Value
end)
ContextActionService:BindAction("Slide", Slide, true, Enum.KeyCode.E)
ContextActionService:BindAction("Wallrun", Wallrun, true, Enum.KeyCode.F)
RunService.Stepped:Connect(function()
if Character:GetAttribute("IsUsingAbility") == false or ClientSlideVelocity.VectorVelocity.Magnitude <= 0 then return end
if os.clock() - TimeAbilityStarted > 3 then StopMovement() return end
local GroundRaycast = workspace:Raycast(HumanoidRootPart.Position, Vector3.new(0, -3.1, 0), RaycastParameters)
local StartPosition = GroundRaycast ~= nil and Character:GetAttribute("LastMovementState") == "Diving" and CFrame.new(GroundRaycast.Position) * HumanoidRootPart.CFrame.Rotation * CFrame.new(0, 1, 3)
or HumanoidRootPart.CFrame * CFrame.new(0, F(Humanoid.HipHeight), 3)
local Raycast = workspace:Blockcast(StartPosition, Vector3.new(2, 1, 2), ClientSlideVelocity.VectorVelocity, RaycastParameters)
if Raycast then
if (Raycast.Instance.Parent:FindFirstChild("Humanoid") and Character:FindFirstChild("Timebomb")) then
StopMovement()
elseif (Raycast.Position - HumanoidRootPart.Position).Magnitude < 4 then
UnitVector.Value = (UnitVector.Value - 2 * UnitVector.Value:Dot(Raycast.Normal) * Raycast.Normal) * Vector3.new(1, 0, 1)
UpdateMagnitudeValue()
end
return
end
end)
the issue will probably be gone by the time i get any help from here but id still like to try