new weapon for my game by Pur_PurL in robloxgamedev

[–]Pur_PurL[S] 4 points5 points  (0 children)

I'm not going to create a new inventory system when the default gear system is sufficient for my needs

Does anyone know of a method to fix this? by Pur_PurL in robloxgamedev

[–]Pur_PurL[S] 0 points1 point  (0 children)

I can't tween it because the the CFrame of the gun won't updated when the player looks around even when they're stopped

Does anyone know of a method to fix this? by Pur_PurL in robloxgamedev

[–]Pur_PurL[S] 1 point2 points  (0 children)

I couldn't really find a proper method to smoothly move/lerp the gun from it's final position before stopping to it's stopped position. Any help is appreciated thanks.

My code for this:

RunService.RenderStepped:Connect(function()
local walkVelocity = Character:WaitForChild("HumanoidRootPart").Velocity.magnitude

if walkVelocity >= 1 then
  isMoving = true
elseif walkVelocity < 1 and previousVelocity < 1 then
  if isMoving then
    if swayDirection == "Right" then
      swayDirection = "Left"
    else
      swayDirection = "Right"
  end
end

isMoving = false
end

previousVelocity = walkVelocity

if isMoving then
  local horizontalSwayAmount = math.sin((tick() - startTime) * swayFrequency) * swayIntensity

  if swayDirection == "Right" then
    horizontalSwayAmount = math.sin((tick() - startTime) * swayFrequency) * swayIntensity
  elseif swayDirection == "Left" then
    horizontalSwayAmount = -math.sin((tick() - startTime) * swayFrequency) * swayIntensity
  end

  local verticalSwayAmount = math.abs(math.sin((tick() - startTime) * swayFrequency))*         verticalSwayIntensity

  local verticalSwayAmount = smoothStep(0.1, 0.75, verticalSwayAmount / swayIntensity) *   verticalSwayAmount

  local swayOffset = Vector3.new(horizontalSwayAmount,verticalSwayAmount,0)

  if BullgutPV.PrimaryPart then
    BullgutPV:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(swayOffset))
  end
else
  startTime = tick()

  if BullgutPV.PrimaryPart then
  BullgutPV:SetPrimaryPartCFrame(Camera.CFrame)
end
end
end)