Morning everyone,
So, I’ve started work on my game and it uses a gun system where the guns have multiple parts (for more defined animations and etc…). My only issue is the previous method of connecting the Motor6D between the parent part and the tool’s attachment part doesn’t work.
Snippet of Code that I use
Summary
Client-side
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.BodyAttach)
char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = WeaponTool.BodyAttach
end)
WeaponTool.Unequipped:Connect(function()
game.ReplicatedStorage.DisconnectM6D:FireServer()
end)
Server-side
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D", char.Torso)
M6D.Name = "ToolGrip"
end)
end)
game.ReplicatedStorage.ConnectM6D.OnServerEvent:Connect(function(plr,location)
local char = plr.Character
char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = location
end)
game.ReplicatedStorage.DisconnectM6D.OnServerEvent:Connect(function(plr)
plr.Character.Torso.ToolGrip.Part1 = nil
end)
The aforementioned method that I use brings up an error message when you reset your character with the tool equipped.
https://gyazo.com/7c67ea64f917d138699728751e63ebbf
The error basically states it cannot find a “ToolGrip” Motor6D, the motor responsible for connecting my tool and the parent part.
My main question is, is there an alternative way to properly connect the Motor6D? Thanks for the assistance!