Took a dash system from someone else on the DevForum, for some reason instead of the position becoming the humanoids root part combined with the DashRange it instead sets the position has 0,0,0 on the workspace, am i missing a piece of code?
local uis = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local humRoot = chr:WaitForChild("HumanoidRootPart")
local DashRange = 200
local DashCD = 3
local CanDash = false
--The Dash itself
function Dash(humRoot,direction)
--Setting Directional Dashes
local position;
if direction == 'forward' then
position = (humRoot.CFrame*CFrame.new(0,0,DashRange)).p
elseif direction == 'backward' then
position = (humRoot.CFrame*CFrame.new(0,0,-DashRange))
end
local i = Instance.new('BodyPosition')
i.MaxForce = Vector3.new(1000000,5,1000000)
i.P = 100000
i.D = 2000
i.Parent = humRoot
coroutine.wrap(function()
wait(0.5)
i:Destroy()
end)()
end
Not the full script, only showed parts that were possibly included in the bug, if you’re interested the main test script looks like this
local tool = script.Parent
local uis = game:GetService("UserInputService")
local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local humRoot = chr:WaitForChild("HumanoidRootPart")
local DashRange = 200
local DashCD = 3
local CanDash = false
--The Dash itself
function Dash(humRoot,direction)
--Setting Directional Dashes
local position;
if direction == 'forward' then
position = (humRoot.CFrame*CFrame.new(0,0,DashRange))
elseif direction == 'backward' then
position = (humRoot.CFrame*CFrame.new(0,0,-DashRange))
end
local i = Instance.new('BodyPosition')
i.MaxForce = Vector3.new(1000000,5,1000000)
i.P = 100000
i.D = 2000
i.Parent = humRoot
coroutine.wrap(function()
wait(0.5)
i:Destroy()
end)()
end
tool.Equipped:Connect(function()
print("tool equipt")
--Sticks and Glue
uis.InputBegan:Connect(function(input,istyping)
if istyping then return end
if input.KeyCode == Enum.KeyCode.R and uis:IsKeyDown(Enum.KeyCode.W) then
if CanDash == true then
CanDash = false
Dash(humRoot,'forward')
print("Dashed forward")
else
CanDash = true
coroutine.wrap(function()
wait(DashCD)
CanDash = false
end)()
end
elseif input.KeyCode == Enum.KeyCode.R and uis:IsKeyDown(Enum.KeyCode.S) then
if CanDash == true then
CanDash = false
Dash(humRoot,'backward')
print("dashed backweards")
else
CanDash = true
coroutine.wrap(function()
wait(DashCD)
CanDash = false
end)()
end
end
end)
end)
Tried both i.Position and i.CFrame.
i.Position = position gives me the error Unable to assign property Position. Vector3 expected, got CFrame
i.CFrame = position gives me the error CFrame is not a valid member of BodyPosition "BodyPosition"