Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How could i make my FP arms smoothly slide into position, rather than roughly teleporting?

Asked by 4 years ago
Edited 4 years ago

I want the FPS arms to smoothly slide into the correct position, but they seem to just teleport into the spot, which makes the arms look ugly.

This is my script that i use -

local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local CharacterBodyColor = Character:WaitForChild("Body Colors")
local ArmBodyColor = Arms:WaitForChild("Body Colors")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Clothing = Character:FindFirstChild("Shirt"):Clone()
local CanTrack = true
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(0.1)

Arms.Name = "Arms"

local function assignArms()
    if CanTrack == true then
        Arms:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(0,-1.2,0.3))
    end
end

local function deleteArms()
    Arms:Destroy()
    CanTrack = false
end

local function adjustArms()
ArmBodyColor.LeftArmColor3 = CharacterBodyColor.LeftArmColor3
ArmBodyColor.RightArmColor3 = CharacterBodyColor.RightArmColor3
Clothing.Parent = Arms
end

Arms.Parent = Camera

adjustArms()

Humanoid.Died:Connect(deleteArms)

RunService.Heartbeat:Connect(assignArms)

Note - I know that i can use RenderStepped, but that wont give the sliding effect to the arms

1 answer

Log in to vote
2
Answered by 4 years ago

Here, you can TweenService, although you have created variables but haven't used it.

Here, we are gonna a new local function for Tween..

-- Setting up variables ..
ArmsV.Value = Arms.PrimaryPart.CFrame

-- If there is blue dash below ArmsV.Value, try making it 'local'.

local function TweenPlayer(object, tween, properties)
    local TweenService = game:GetService("TweenService")
    local TweenInfo = TweenInfo.new(tween, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
    local Tween = TweenService:Create(object, TweenInfo, properties)
    Tween:Play()
    return Tween
end

Now to run your Tween, you can simply do:

-- Add Cframe change detecter

ArmsV.Changed:Connect(function(value)
    Arms:SetPrimaryPartCFrame(value)
end)

-- Triggering the TweenPlayer function
TweenPlayer(ArmsV, 3, CFrame.new(0, -1.2, 0.3)

Setting up above things in your script..

local Camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local CharacterBodyColor = Character:WaitForChild("Body Colors")
local ArmBodyColor = Arms:WaitForChild("Body Colors")
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local Clothing = Character:FindFirstChild("Shirt"):Clone()
local CanTrack = true

Arms.Name = "Arms"
ArmsV.Value = Arms.PrimaryPart.CFrame

-- If there is blue dash below ArmsV.Value, try making it 'local'.

local function TweenPlayer(object, tween, properties)
    local TweenService = game:GetService("TweenService")
    local TweenInfo = TweenInfo.new(tween, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
    local Tween = TweenService:Create(object, TweenInfo, properties)
    Tween:Play()
    return Tween
end

--[[ local function assignArms()
    if CanTrack == true then
        Arms:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(0,-1.2,0.3))
    end
end ]] --

ArmsV.Changed:Connect(function(value)
    Arms:SetPrimaryPartCFrame(value)
end)

local function deleteArms()
    Arms:Destroy()
    CanTrack = false
end

local function adjustArms()
ArmBodyColor.LeftArmColor3 = CharacterBodyColor.LeftArmColor3
ArmBodyColor.RightArmColor3 = CharacterBodyColor.RightArmColor3
Clothing.Parent = Arms
end

Arms.Parent = Camera

adjustArms()

Humanoid.Died:Connect(deleteArms)

RunService.Heartbeat:Connect(TweenPlayer(ArmsV, 3, CFrame.new(0, -1.2, 0.3))

Lemme know if it helps!

Ad

Answer this question