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 -

01local Camera = workspace.CurrentCamera
02local RunService = game:GetService("RunService")
03local CharacterBodyColor = Character:WaitForChild("Body Colors")
04local ArmBodyColor = Arms:WaitForChild("Body Colors")
05local Humanoid = Character:FindFirstChildOfClass("Humanoid")
06local Clothing = Character:FindFirstChild("Shirt"):Clone()
07local CanTrack = true
08local TS = game:GetService("TweenService")
09local Info = TweenInfo.new(0.1)
10 
11Arms.Name = "Arms"
12 
13local function assignArms()
14    if CanTrack == true then
15        Arms:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(0,-1.2,0.3))
View all 36 lines...

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..

01-- Setting up variables ..
02ArmsV.Value = Arms.PrimaryPart.CFrame
03 
04-- If there is blue dash below ArmsV.Value, try making it 'local'.
05 
06local function TweenPlayer(object, tween, properties)
07    local TweenService = game:GetService("TweenService")
08    local TweenInfo = TweenInfo.new(tween, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
09    local Tween = TweenService:Create(object, TweenInfo, properties)
10    Tween:Play()
11    return Tween
12end

Now to run your Tween, you can simply do:

1-- Add Cframe change detecter
2 
3ArmsV.Changed:Connect(function(value)
4    Arms:SetPrimaryPartCFrame(value)
5end)
6 
7-- Triggering the TweenPlayer function
8TweenPlayer(ArmsV, 3, CFrame.new(0, -1.2, 0.3)

Setting up above things in your script..

01local Camera = workspace.CurrentCamera
02local RunService = game:GetService("RunService")
03local CharacterBodyColor = Character:WaitForChild("Body Colors")
04local ArmBodyColor = Arms:WaitForChild("Body Colors")
05local Humanoid = Character:FindFirstChildOfClass("Humanoid")
06local Clothing = Character:FindFirstChild("Shirt"):Clone()
07local CanTrack = true
08 
09Arms.Name = "Arms"
10ArmsV.Value = Arms.PrimaryPart.CFrame
11 
12-- If there is blue dash below ArmsV.Value, try making it 'local'.
13 
14local function TweenPlayer(object, tween, properties)
15    local TweenService = game:GetService("TweenService")
View all 49 lines...

Lemme know if it helps!

Ad

Answer this question