local dashBE = script.Parent
local lp = game:GetService("Players").localPlayer
local char = lp.Character
local hrp: Part = char:WaitForChild("HumanoidRootPart")
local hum: Humanoid = char:WaitForChild("Humanoid")
local animator: Animator = hum:WaitForChild("Animator")
local dashDuration = 0.35
local rate = 0.01
dashBE.OnInvoke = function(dashDirection)
local bv= Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(100000, 0, 100000)
bv.Parent = hrp
local dashStrength = 100
local mds = dashDuration * 0.15
local amountOfIterations = dashDuration / rate
local removalOfStrengthPerIteration = dashStrength / amountOfIterations
for i = 0, dashDuration, rate do
if dashDirection == "Front" then
bv.Velocity = hrp.CFrame.LookVector * dashStrength
elseif dashDirection == "Back" then
bv.Velocity = (hrp.CFrame.LookVector * -1) * dashStrength
elseif dashDirection == "Right" then
bv.Velocity = hrp.CFrame.RightVector * dashStrength
elseif dashDirection == "Left" then
bv.Velocity = (hrp.CFrame.RightVector * -1) * dashStrength
end
if dashStrength > mds then
dashStrength -= removalOfStrengthPerIteration
if dashStrength < mds then
dashStrength = mds
end
end
task.wait(rate)
end
bv:Destroy()
end
#attempt to index nil with 'Character'
1 messages · Page 1 of 1 (latest)
** You are now Level 3! **
It was working fine earlier now I'm getting an erro saying attempt to index nil with character
local uis = game:GetService("UserInputService")
local dashBE = script:WaitForChild("Dash")
uis.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.KeyCode == Enum.KeyCode.Q then
local dashDirection = "Front"
if uis:IsKeyDown(Enum.KeyCode.A) then
local dashDirection = "Left"
elseif uis:IsKeyDown(Enum.KeyCode.D) then
local dashDirection = "Right"
elseif uis:IsKeyDown(Enum.KeyCode.W) then
local dashDirection = "Back"
end
dashBE:Invoke(dashDirection)
end
end
end)
This is also important since it is the script parent and calls to the script
try this @high spade
lp.Character or lp.CharacterAdded:Wait()
as the character may have not loaded in yet that’s why it is nil
in which set of code should I add it?
The full error is Workspace.kIefkey.InputManager.Dash.Script:4: attempt to index nil with 'Character'
where do you think
I put it into the InputManager local script and it did nothing let me try the Dash Script
put it where ??
It's two different scripts one is used to detect the direction while the other is used to actually move the character based on the hrp
Yes it was working before but its not working anymore
New to scripting or?
Kind of I have some python experience but that doesnt transfer very well
It transfers great
In your output it tells you which line and script the error is from
You don’t just copy and paste the line I sent anywhere in your script with no purpose 😂
Add it to where you define the character variable
local dashBE = script.Parent
local lp = game:GetService("Players").localPlayer
local char = lp.CharacterAdded:Wait()
local hrp: Part = char:WaitForChild("HumanoidRootPart")
local hum: Humanoid = char:WaitForChild("Humanoid")
local animator: Animator = hum:WaitForChild("Animator")
local dashDuration = 0.35
local rate = 0.01
dashBE.OnInvoke = function(dashDirection)
local bv= Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(100000, 0, 100000)
bv.Parent = hrp
local dashStrength = 100
local mds = dashDuration * 0.15
local amountOfIterations = dashDuration / rate
local removalOfStrengthPerIteration = dashStrength / amountOfIterations
for i = 0, dashDuration, rate do
if dashDirection == "Front" then
bv.Velocity = hrp.CFrame.LookVector * dashStrength
elseif dashDirection == "Back" then
bv.Velocity = (hrp.CFrame.LookVector * -1) * dashStrength
elseif dashDirection == "Right" then
bv.Velocity = hrp.CFrame.RightVector * dashStrength
elseif dashDirection == "Left" then
bv.Velocity = (hrp.CFrame.RightVector * -1) * dashStrength
end
if dashStrength > mds then
dashStrength -= removalOfStrengthPerIteration
if dashStrength < mds then
dashStrength = mds
end
end
task.wait(rate)
end
bv:Destroy()
end
so show output
No
Your trying to get the local player in a server script
I don't get what you mean
no
well that’s literally the core of roblox scripting
so i advise learn that before trying to make these systems
localplayer is only accessible in a local script
where did u get this code from
I made it myself and as I said it was working I don't know why it stopped
make it a local script
Fixed the error but now the dash isnt working
** You are now Level 4! **
Idk who told you that
But they can't script for shit.
All the scripts from StarterCharacterScripts are trasnferred to the players character on spawn. If server scripts couldnt function properly when parented to the character then Roblox's health script wouldn't exist.
LocalPlayer, not localPlayer
I already gott it to work