When I use dash/roll for the first time while joining the game it bugs out

  1. **What do you want to achieve?
    I want my roll script to not bug out when I dash/roll for the first time when I join the game.

  2. **What is the issue?
    When I join the game the first roll/dash sends my camera to y cordinates 340282346638528859811704183484516925440.

  3. **What solutions have you tried so far?
    None. I have tried doing some math but i’m not the brightest person so i couldn’t figure it out.

local Movement = {
	["Sprint"] = function(Player, Params)
		
	end,
	["Dash"] = function(Player, Params, UserInput)
		local Character = Player.Character or Player.CharacterAdded:Wait()
		local HRP = Character:WaitForChild("HumanoidRootPart")
		local humanoid = Character:WaitForChild("Humanoid")
		local Roll = humanoid:LoadAnimation(script:WaitForChild("Roll"))
		Roll.Priority = Enum.AnimationPriority.Action
		local Debounce = false
		local RollStartTime = 0
		local RollDirection = Vector3.new()
		local RollMult = 15/Roll.Length

		Debounce = true
		
		Roll:Play()
		RollStartTime = tick()
		local dirVec = workspace.CurrentCamera.CFrame.LookVector
		RollDirection =  (dirVec*Vector3.new(1,0,1)).unit
		
		local LastBeat = tick()
		game:GetService("RunService").Heartbeat:Connect(function()
			local dT = tick()-LastBeat
			LastBeat = tick()

			if tick()-RollStartTime < .75 then
				HRP.CFrame = CFrame.new(RollDirection*dT*RollMult) * HRP.CFrame
			end
		end) 
		
		Debounce = false
	end,
}

return Movement

1 Like

And my character origin changes to -1000000 sometimes.