This might be dumb question but. I’m trying to get a attachment to follow the weapon as it plays animation. Thang is the model has armature from blender and the animation is done in blender. Once you import it into studio. Lets say you try to weld part or even use motor6d to connect to the model when you play animation that part doesn’t move with the model, same with attachments. I have parts rigged up with model that I have tried to use in script to make the attachment follow the part But no luck. So I’m hoping maybe someone found away around this that could help me out.
Here’s a video of the model with with attachment hooked up with it.
This is the script. In it you can see I instance a new attachment trying to make it follow the weapon as it play animation but does the same thing in the video.
local backpack = game.Players.LocalPlayer.Backpack
-------------------------------------------------
-- View Set
-------------------------------------------------
local cam = workspace.Camera
local gun= script.Parent.Parent.VModel
local newTool = Instance.new("Tool")
newTool.Name = script.Parent.Name
newTool.Parent = backpack
gun.Parent = newTool
-------------------------------------------------
local rs = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local mouse = player:GetMouse()
local remote = script.Parent.CastAndRemote:FindFirstChild("FirstRemote")
-------------------------------------------------------------
--animation
-------------------------------------------------------------
local animCon = script.Parent.AnimationController
local anim01 = script.Parent.Animation.Reload
local Reload = animCon:LoadAnimation(anim01)
-------------------------------------------------------------
-------------------------------------------------------------
--Reload:Play()
local att = Instance.new("Attachment")
att.Parent = script.Parent.Attachment04
att.Visible = true
rs.RenderStepped:Connect(function()
gun:SetPrimaryPartCFrame(cam.CFrame * CFrame.new(0,0,0))
att.WorldPosition = script.Parent.Attachment04.Position
end)
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("works")
remote:FireServer(mouse.Hit.Position)
end
end)