Also do you know why the body of the player moves like this with the bobble?
I made a First Person Body
script
which changes the LocalTransparencyModifier.
But then I saw that this occurs, why?
You can set the BobbleSpeed variable to Humanoid.WalkSpeed multiplied by some number like 5/10 every frame (this number means that the bobble speed will be 5 when the Humanoid.WalkSpeed is 10)
This seems to occur when you directly change the CFrame of the camera instead of using Humanoid.CameraOffset, you can fix it by removing this
* CFrame.new(X, Y, 0)
line of code from the line where the code changes the camera CFrame
and add a new line of code which sets the Humanoid.CameraOffset like this
Humanoid.CameraOffset = Vector3.new(X, Y, 0)
How would I make it so that tools are attached to the right hand of the custom view model which you can see in the videos which I sent.
I’ve tried using WeldConstraints, loops to set the CFrame of the Handle to the hand but none of them worked.
Code
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = (Character:FindFirstChild("Head") :: BasePart)
local Camera = workspace.Camera
local RunService = game:GetService("RunService")
local ViewModel: Model = game.ReplicatedStorage.ViewModel:Clone()
ViewModel.Parent = Camera
Player.Character:WaitForChild("Body Colors"):Clone().Parent = ViewModel;
Player.Character:WaitForChild("Shirt"):Clone().Parent = ViewModel;
Player.Character:WaitForChild("Pants"):Clone().Parent = ViewModel;
local VMHumanoid = ViewModel:FindFirstChildWhichIsA("Humanoid");
local VMAnimator = VMHumanoid:FindFirstChild("Animator") :: Animator;
local VMAnimSaves = ViewModel:FindFirstChild("Animations") :: Model;
local VMBobble = VMAnimator:LoadAnimation(VMAnimSaves:WaitForChild("Bobble"));
local VMHold = VMAnimator:LoadAnimation(VMAnimSaves:WaitForChild("BobbleHoldItem"));
VMHold.Priority = Enum.AnimationPriority.Action4;
local VMRightArm = ViewModel:WaitForChild("Right Arm") :: BasePart;
local VMToolHandle = VMRightArm:WaitForChild("ToolHandle") :: BasePart;
local toolCheck = function(tool: Tool): ()
local equipped: boolean = false;
local weld: WeldConstraint = Instance.new("WeldConstraint");
local handle = tool:WaitForChild("Handle") :: BasePart;
tool.Equipped:Connect(function(): ()
if not (VMHold.IsPlaying) then
VMHold:Play();
equipped = true;
end;
end);
tool.Unequipped:Connect(function(): ()
if (VMHold.IsPlaying) then
VMHold:Stop();
equipped = false;
end;
end);
end;
RunService.RenderStepped:Connect(function()
if Player.Character.Humanoid.Health == 0 then
if Camera:FindFirstChild("ViewModel") ~= nil then
ViewModel:Destroy()
end
end
if Camera:FindFirstChild("ViewModel") ~= nil then
--Camera.CFrame * CFrame.new(.025, -1.5, -.1) * CFrame.Angles(0.3, 0, 0)
ViewModel:PivotTo(Camera.CFrame * CFrame.new(.025, -2, -.3) * CFrame.Angles(0.3, 0, 0))
end
if (Character:FindFirstChildWhichIsA("Humanoid").MoveDirection.Magnitude > 0) then
if not (VMBobble.IsPlaying) then
VMBobble:Play();
end;
else
if (VMBobble.IsPlaying) then
VMBobble:Stop();
end;
end;
for i: number, v: Tool in ipairs(Player.Backpack:GetChildren()) do
if v:IsA("Tool") then
toolCheck(v);
end;
end;
end)
Thank you so much again Denko!
This is off topic to the current discussion, open a new topic instead
--[[
50 chars
]]