Hello. I am trying to make a vending machine where it dispenses a tool, a conveyor brings it to an opening, and an impulse is applied to make it fall out. I have the impulse applied at the correct direction, but the tool just bounces everywhere, even after removing the parts around it. I can provide a video if needed. Thanks.
You can just increase its density using CustomPhysicalProperties or increase its mass.
make sure to apply impulse after you have set the parent
local part = ...
part.Parent = workspace
part:ApplyImpulse(force) -- apply impulse after we set the parent
I probably should’ve provided the script.
for _, button in pairs(script.Parent:GetChildren()) do
if button:IsA("BasePart") and button:FindFirstChild("ClickDetector") then
button.ClickDetector.MouseClick:Connect(function(player)
local gear = game.ReplicatedStorage.ExtraModels.VendingMachine:FindFirstChild(button.Name):Clone()
gear.Parent = script.Parent.Spawned
local val = Instance.new("NumberValue")
val.Parent = gear
val.Value = #script.Parent.Spawned:GetChildren()
gear:WaitForChild("Handle").CFrame = script.Parent.SpawnPos.CFrame
if #script.Parent.Spawned:GetChildren() >= 2 then
local min = 10
local minChild = nil
for i, child in pairs(script.Parent.Spawned:GetChildren()) do
if child:FindFirstChild("Value") then
if child.Value.Value < min then
min = child.Value.Value
minChild = child
end
end
end
minChild:Destroy()
end
end)
end
end
script.Parent.Model.ImpulsePart2.Touched:Connect(function(hit)
print(hit:GetFullName())
if hit.Name == "Handle" and not hit:FindFirstChild("_done") then
local attachment = Instance.new("Attachment")
attachment.Parent = hit
local velocity = Instance.new("VectorForce")
velocity.Parent = hit
velocity.Attachment0 = attachment
local done = Instance.new("BoolValue")
done.Name = "_done"
done.Parent = hit
velocity.Force = Vector3.new(-10, 0, 0)
wait(1)
velocity.Parent = nil
end
end)
Mass is read only, and increasing the density doesn’t do anything
Alright, I got it to work. It turns out that the conveyor moving it was too large for the tool. Thanks for your help
Oh I thought the problem was that the part was bouncing too much because of its low mass. By increasing the mass I meant adding an inivisble part thats larger which will increase the mass.
Oh, makes sense. I don’t want to do that because these are being used as tools and I don’t want to change the tool grip.