Problem With LinearVelocity

Here’s a video where i test it on studio:

And here’s when i test it on roblox:

And finally here is my dashing script:

local rp = game:GetService(“ReplicatedStorage”)
local remotes = rp:WaitForChild(“Remotes”)

local backBL = remotes:WaitForChild(“Back”)

local punchEvent = remotes:WaitForChild(“Punch”)
local blockEvent = remotes:WaitForChild(“Block”)

local player = game:GetService(“Players”).LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”)
local humRp = char:WaitForChild(“HumanoidRootPart”)

local camera = workspace.CurrentCamera

local dashEvent = remotes:WaitForChild(“Dash”)

local gameSettings = UserSettings().GameSettings

local canDash = remotes:WaitForChild(“CanDash”)
local canDash2 = remotes:WaitForChild(“CanDash2”)

local dashAnimations = rp:WaitForChild(“Anims”):WaitForChild(“Movement”)

local UIS = game:GetService(“UserInputService”)
local dashing = false
local stop = false

dashEvent.OnClientEvent:Connect(function()
stop = true
end)

player.CharacterAdded:Connect(function(charactermodel)
hum:SetStateEnabled(Enum.HumanoidStateType.Climbing, false)
char = charactermodel
hum = char:WaitForChild(“Humanoid”)
humRp = char:WaitForChild(“HumanoidRootPart”)
end)

local function smoothDash(front,currDirection)

if front then

	local checkCanDash = canDash:InvokeServer()

	if not checkCanDash then
		return
	end

	dashEvent:FireServer(front,currDirection)

	local dashAnim = dashAnimations["DashFront"]
	local playDashAnim = hum:GetPlayingAnimationTracks()[dashAnim.Name] or hum:LoadAnimation(dashAnim)

	playDashAnim:Play()

local A0 = Instance.new(“Attachment”)
A0.Parent = humRp
local bv = Instance.new(“LinearVelocity”)
bv.MaxForce = 100000
bv.Parent = humRp
bv.Attachment0 = A0
for i=100,0,-2 do
if not stop then
bv.VectorVelocity = humRp.CFrame.LookVector * i
hum.JumpHeight = 0
task.wait()

		else
			break
		end
	end
	hum.JumpHeight = 7.2
	playDashAnim:Stop()

	if stop then
		hum.JumpHeight = 7.2
		local dashAnimAttack = dashAnimations["DashFrontAttack"]
		local playDashAnimAttack = hum:GetPlayingAnimationTracks()[dashAnimAttack.Name] or hum:LoadAnimation(dashAnimAttack)

		playDashAnimAttack:Play()
		task.delay(0.1,function()
			playDashAnimAttack:Stop()
		end)
	end
	stop = false
	bv:Destroy()
else
	local checkCanDash2 = canDash2:InvokeServer()

	if not checkCanDash2 then
		return
	end

	dashEvent:FireServer(front,currDirection)

	gameSettings.RotationType = Enum.RotationType.CameraRelative

local A0 = Instance.new(“Attachment”)
A0.Parent = humRp
local bv = Instance.new(“LinearVelocity”)
bv.MaxForce = 100000
bv.Parent = humRp
bv.Attachment0 = A0
local currAnim
if currDirection == “Left” then
currAnim = dashAnimations[“DashLeft”]
elseif currDirection == “Right” then
currAnim = dashAnimations[“DashRight”]
elseif currDirection == “Back” then
currAnim = dashAnimations[“DashBack”]
end

	local playDash = hum:GetPlayingAnimationTracks()[currAnim.Name] or hum:LoadAnimation(currAnim)
	playDash:Play()

	for i=100,0,-3 do
		if currDirection == "Left" then
			bv.VectorVelocity = humRp.CFrame.RightVector * -i
		elseif currDirection == "Right" then
			bv.VectorVelocity = humRp.CFrame.RightVector * i
		elseif currDirection == "Back" then
			bv.VectorVelocity = humRp.CFrame.LookVector * -i
			task.delay(.5,function()
				bv.VectorVelocity = humRp.CFrame.LookVector * -i
			end)
		end
		hum.JumpHeight = 0
		humRp.CFrame += Vector3.new(0,0.05,0)
		if currDirection == "Back" then
		backBL.Value = true
		else
			backBL.Value = false
		end
		task.wait()

	end
	if currDirection ~= "Back" then
		hum.JumpHeight = 7.2
		playDash:Stop()
	bv:Destroy()
	else		
		playDash:AdjustSpeed(2)
		task.delay(.5,function()
			hum.JumpHeight = 7.2
			playDash:Stop()
			bv:Destroy()
		end)
	end
	gameSettings.RotationType = Enum.RotationType.MovementRelative
end

end

UIS.InputBegan:Connect(function(input, isTyping)
if isTyping then return end

if input.KeyCode == Enum.KeyCode.Q then
local moveDirection = camera.CFrame:VectorToObjectSpace(hum.MoveDirection)

	local left = math.round(moveDirection.X) == -1
	local right = math.round(moveDirection.X) == 1
	local front = math.round(moveDirection.Z) == -1
	local back = math.round(moveDirection.Z) == 1

	local frontDash = false
	local currDirection = nil

	if left then
		currDirection = "Left"
	elseif right then
		currDirection = "Right"
	elseif front then
		frontDash = true
	elseif back then
		currDirection = "Back"
	else
		frontDash = true
	end
	smoothDash(frontDash,currDirection)
	dashEvent:FireServer(front,currDirection)
end

end)

Weird, works on studio but not on roblox?

oop, nvm Just fixed it, set roblox studio access to api whatever on and it worked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.