Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I allow specific parts disconnect from a tool?

Currently I am building a Pistol tool, I have mostly everything from the model, the shooting and Gui along with the muzzle flash. Now I am currently on the animations and one thing i desire to specifically do is to have the "cocking" mechanism move back in order for the bullet casing to exit. I've managed to finish practically the code for it and now it does move back as desires, one problem though, when it moves back it brings the rest of the tool along with me with it meaning I am pushed back far whenever I shoot.

Basically I desire that the mechanism move back separately and not shake the rest of my gun out of proportion, I think it could possibly be due to the welds it has but i'm not completely sure.

--Variables:
local markev = script.Parent

local mech = markev:FindFirstChild("Mech")
local mechall = mech:GetChildren()

local Primary = mech:WaitForChild("PrimaryPart")
mech.PrimaryPart = Primary

local Timec = 0.1
local Increment = 0.1

local PrimePos = Primary.Position
local newPos = PrimePos + Vector3.new(0,0,-0.2)

local Diff = newPos - PrimePos 
local Mag = Diff.magnitude 
local Direction = CFrame.new(PrimePos, newPos).lookVector

--This is the specific section of the script where it shoots and the command to move it back:

for n = 0, Mag, Increment do
	Primary.CFrame = Primary.CFrame + (Direction * Increment)
	wait( (Timec/Mag) * Increment )
end

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.