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!
I want to fix my script because every time a player dies for the first time it breaks -
What is the issue? Include screenshots / videos if possible!
Wallrunning after death triggers the script for 1 frame -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried looking for solutions, tried resetting stuff after players die, and more but none of it works
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
module script:
local MovementModule = {}
MovementModule.__index = MovementModule
local Distance = 4
local MaxTime = 2
local Accuracy = .5
function MovementModule.CreateStats(Player)
local NewMovement = setmetatable({}, MovementModule)
NewMovement.Player = Player
NewMovement.Wallrunning = false
NewMovement.WallrunDebounce = false
NewMovement.DashDebounce = false
NewMovement.Player.CharacterAdded:Connect(function()
print("module detected respawn")
NewMovement.Wallrunning = false
NewMovement.WallrunDebounce = false
NewMovement.DashDebounce = false
NewMovement.Player = Player
end)
return NewMovement
end
function MovementModule:Wallrun()
local Player = self.Player
local hrp = Player.Character.HumanoidRootPart
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {Player.Character:GetDescendants()}
local Wallrun = coroutine.create(function()
local StartTime = tick()
self.Player.PlayerGui.CooldownUI.Frame.Wallrun.Slider.BackgroundColor = BrickColor.new(255, 0, 0)
while self.Wallrunning do
wait(.01)
local rayL = workspace:Raycast(hrp.Position, hrp.CFrame.RightVector * -Distance, raycastParams)
local rayR = workspace:Raycast(hrp.Position, hrp.CFrame.RightVector * Distance, raycastParams)
if Player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Landed then
if rayL or rayR then
if tick() - StartTime <= MaxTime then
if rayL then
local Normal = rayL.Normal
local Direction = Normal:Cross(Vector3.new(0,1,0))
Direction = -Direction
local Character = Player.Character
local Vector = (Direction * Character.Humanoid.WalkSpeed * 2 + Vector3.new(0, Character.HumanoidRootPart.Velocity - Character.HumanoidRootPart.Velocity)).Unit
hrp.Velocity = math.clamp((Character.HumanoidRootPart.Velocity * (1)).Magnitude, 40, 50 ) * Vector + Vector3.new(0, Character.HumanoidRootPart.Velocity.Y + workspace.Gravity / 33, 0)
elseif rayR then
local Normal = rayR.Normal
local Direction = Normal:Cross(Vector3.new(0,1,0))
local Character = Player.Character
local Vector = (Direction * Character.Humanoid.WalkSpeed * 2 + Vector3.new(0, Character.HumanoidRootPart.Velocity - Character.HumanoidRootPart.Velocity)).Unit
hrp.Velocity = math.clamp((Character.HumanoidRootPart.Velocity * (1)).Magnitude, 40, 50 ) * Vector + Vector3.new(0, Character.HumanoidRootPart.Velocity.Y + workspace.Gravity / 33, 0)
end
else
self.Wallrunning = false
coroutine.yield()
end
else
self.Wallrunning = false
coroutine.yield()
end
else
self.Wallrunning = false
coroutine.yield()
end
end
end)
if self.Wallrunning == true then
self.Wallrunning = false
self.WallrunDebounce = true
hrp.Velocity = Vector3.new(hrp.Velocity.X, 50, hrp.Velocity.Z)
end
local rayL = workspace:Raycast(hrp.Position, hrp.CFrame.RightVector * -Distance, raycastParams)
local rayR = workspace:Raycast(hrp.Position, hrp.CFrame.RightVector * Distance, raycastParams)
if Player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
if rayL or rayR then
if not self.WallrunDebounce then
self.Wallrunning = true
hrp.Velocity = Vector3.new(hrp.Velocity.X, hrp.Velocity.Y / 3, hrp.Velocity.Z)
coroutine.resume(Wallrun)
end
end
end
end
function MovementModule:Dash()
if not self.DashDebounce then
local Player = self.Player
Player.PlayerGui.CooldownUI.Frame.Wallrun.Slider.BackgroundColor = BrickColor.Blue()
local hrp = Player.Character.HumanoidRootPart
self.DashDebounce = true
self.WallrunDebounce = false
hrp.Velocity = (hrp.CFrame.LookVector * 150) + Vector3.new(0, 45, 0)
local StartScale = Player.PlayerGui.CooldownUI.Frame.Dash.Slider.Size
Player.PlayerGui.CooldownUI.Frame.Dash.Slider.Size = UDim2.new(0, 0, 0, 50)
repeat
Player.PlayerGui.CooldownUI.Frame.Dash.Slider.Size += UDim2.new(0, 2.5, 0, 0)
wait(((200 / 2.5) / (200 / 2.5 / 2.5)) / (200 / 2.5))
until Player.PlayerGui.CooldownUI.Frame.Dash.Slider.Size == StartScale
self.DashDebounce = false
end
end
return MovementModule
local script:
script.Parent:WaitForChild("PlayerModule"):WaitForChild("CameraModule"):WaitForChild("MouseLockController"):WaitForChild("BoundKeys").Value = "LeftControl"
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local InputService = game:GetService("UserInputService")
local MovementModule = require(game:GetService("ReplicatedStorage").Movement)
local Movement = MovementModule.CreateStats(Player)
InputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Space then
Movement:Wallrun()
end
if Input.KeyCode == Enum.KeyCode.LeftShift then
Movement:Dash()
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if Character.Humanoid:GetState() ~= (Enum.HumanoidStateType.Freefall) then
Player.PlayerGui.CooldownUI.Frame.Wallrun.Slider.BackgroundColor = BrickColor.Blue()
Movement.WallrunDebounce = false
Movement.Wallrunning = false
end
end)
Player.CharacterAdded:Connect(function()
Movement.Wallrunning = false
Movement.WallrunDebounce = false
Movement.DashDebounce = false
end)