Hi,
I have two things I need help with.
1- I was trying to replicate what Headstackk did in this topic:
But the problem is that in the 53rd post Headstackk solved his problem and didn’t show how. The problem he was having was that he couldn’t get his viewmodel to replicate the player’s real arm movement.
2- Another thing I need help with is trying to get the player’s real arms to move with the camera how the viewmodel arms do, just like in the 64th post.
I’ve been having trouble recreating what he did and I’m looking for some help.
My Scripts So Far:
StarterGui Local Script
local LocalPlayer = game:GetService("Players").LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local ViewModel = game:GetService("ReplicatedStorage").ViewModel:Clone()
local ViewModelRoot = ViewModel.PrimaryPart
local camera = workspace.CurrentCamera
ViewModel.Parent = workspace
RunService.RenderStepped:Connect(function ()
ViewModelRoot.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0, -1.5, 0)
ViewModel.Torso["Left Shoulder"].Transform = Character.Torso["Left Shoulder"].Transform
ViewModel.Torso["Right Shoulder"].Transform = Character.Torso["Right Shoulder"].Transform
Character["Right Arm"].LocalTransparencyModifier = Character["Right Arm"].Transparency
Character["Left Arm"].LocalTransparencyModifier = Character["Left Arm"].Transparency
end)
local shoulders = {Character:WaitForChild("Torso"):WaitForChild("Right Shoulder"), Character:WaitForChild("Torso"):WaitForChild("Right Shoulder")}
RunService.Stepped:Connect(function()
local cameraCFrame = camera.CFrame
for _, motor in ipairs(shoulders) do
local cameraOffset = motor.Part0.CFrame * motor.Part0.CFrame:Inverse()
local offset = motor.C0 * motor.C1:Inverse()
local newLocation = camera.CFrame * cameraOffset * offset
local oldLocation = motor.Part0.CFrame * offset
motor.Transform = motor.Transform * oldLocation:Inverse() * newLocation
end
end)
Local Script In My Weapon:
local plr = game.Players.LocalPlayer
local tool = script.Parent
local bodyAttach = tool:WaitForChild("BodyAttach")
local rs = game.ReplicatedStorage
local eventsFolder = rs:WaitForChild("Events")
local DisconnectM6D = eventsFolder:WaitForChild("DisconnectM6D")
local ConnectM6D = eventsFolder:WaitForChild("ConnectM6D")
tool.Equipped:Connect(function()
local char = plr.Character or plr.CharacterAdded:Wait()
ConnectM6D:FireServer(bodyAttach)
char:WaitForChild("Torso"):WaitForChild("ToolGrip").Part0 = char:WaitForChild("Torso")
char:WaitForChild("Torso"):WaitForChild("ToolGrip").Part1 = bodyAttach
char:WaitForChild("Humanoid"):LoadAnimation(script:WaitForChild("UspIdle")):Play(0)
end)
tool.Unequipped:Connect(function()
DisconnectM6D:FireServer()
tool.Unequipped:Connect(function()
local char = plr.Character or plr.CharacterAdded:Wait()
DisconnectM6D:FireServer()
local AnimationTracks = char:WaitForChild("Humanoid"):GetPlayingAnimationTracks()
for i, track in pairs (AnimationTracks) do
if script:FindFirstChild(track.Name) then
track:Stop(0)
end
end
end)
end)
Server Script In ServerScriptService
local rs = game.ReplicatedStorage
local eventsFolder = rs:WaitForChild("Events")
local DisconnectM6D = eventsFolder:WaitForChild("DisconnectM6D")
local ConnectM6D = eventsFolder:WaitForChild("ConnectM6D")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D", char.Torso)
M6D.Name = "ToolGrip"
end)
end)
ConnectM6D.OnServerEvent:Connect(function(plr,location)
local char = plr.Character
char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = location
end)
DisconnectM6D.OnServerEvent:Connect(function(plr)
plr.Character.Torso.ToolGrip.Part1 = nil
end)