--throw molotov
throwAnim:GetMarkerReachedSignal("throwMolotov"):Connect(function()
--create variable for force
local force = Vector3.new(0, -500, -2000)
--reparent tool to workspace
tool.Parent = game.Workspace
--delete touchinterest
tool.Handle.TouchInterest:Destroy() --THIS LINE
--add vectorforce to send it flying
local attachment = Instance.new("Attachment")
attachment.Parent = tool.Handle
local vectorForce = Instance.new("VectorForce")
vectorForce.Attachment0 = attachment
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
vectorForce.ApplyAtCenterOfMass = true
vectorForce.Force = force
vectorForce.Parent = tool.Handle
game.Debris:AddItem(vectorForce, .1)
--hit detection for bottle explosion upon impact
tool.Handle.Touched:Connect(function(hit) --AND THIS LINE
if hit:FindFirstAncestor("Map") or hit.Name == "Baseplate" then
print("KABOOOOOM")
else
print("did not hit map")
end
end)
end)
When I throw the molotov, I delete the touch interest. This is to prevent a player from picking up the molotov when it is thrown.
However, the touched event at the bottom of the script doesn’t work if I do that. Afterwards, however, I removed the line that deletes the touch interest, and it works fine.
However, of course, I am then able to pick up the tool.
NOTE: Yes, since the molotov explodes into fire when it hits something this probably wouldn’t be a huge issue, but I predict it will end up being buggy if I don’t fix this, so I’d rather knock it out here.