Why is my tool falling THROUGH the floor?

  1. What do you want to achieve?
    ~ I want the tool to land on the floor after being thrown.

  2. What is the issue?
    ~ The tool falls straight through the floor.

  3. What solutions have you tried so far?
    ~ Google/DevForum/ChatGPT couldn’t find any answers.

So here is the Script in ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Create the RemoteEvent if it doesn't exist
local throwEvent = ReplicatedStorage:FindFirstChild("ThrowEvent")
if not throwEvent then
    throwEvent = Instance.new("RemoteEvent")
    throwEvent.Name = "ThrowEvent"
    throwEvent.Parent = ReplicatedStorage
end

local GRAVITY = Vector3.new(0, -196.2, 0)

throwEvent.OnServerEvent:Connect(function(player, tool, throwPosition, initialVelocity)
    local character = player.Character
    if not character or not tool:IsDescendantOf(character) then return end
    
    -- Create a clone of the tool to throw
    local handle = tool:FindFirstChild("Handle")
    if not handle then return end
    
    local thrownTool = handle:Clone()
    thrownTool.Parent = workspace
    thrownTool.CFrame = CFrame.new(throwPosition)
    
    -- Apply initial velocity to simulate the throw
    local bodyVelocity = Instance.new("BodyVelocity")
    bodyVelocity.Velocity = initialVelocity
    bodyVelocity.P = 5000  -- Power of the force
    bodyVelocity.MaxForce = Vector3.new(5000, 5000, 5000)  -- Maximum force that can be applied
    bodyVelocity.Parent = thrownTool
    
    -- Apply gravity to the object
    local bodyForce = Instance.new("BodyForce")
    bodyForce.Force = GRAVITY * thrownTool:GetMass()
    bodyForce.Parent = thrownTool
    
    -- Remove BodyVelocity after some time to allow natural fall
    game.Debris:AddItem(bodyVelocity, 0.5)
    
    -- Cleanup after some time
    game.Debris:AddItem(thrownTool, 35)
end)

And here is the Local Script inside the tool…

-- LocalScript inside the tool
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = Players.LocalPlayer
local tool = script.Parent
local throwEvent = ReplicatedStorage:WaitForChild("ThrowEvent")

local function onActivated()
	
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
	local mouse = player:GetMouse()
	
	
	local handle = tool.Handle
	-- Define the desired mass in kilograms
	local desiredMass = 5
	-- Get the current mass of the handle
	local currentMass = handle:GetMass()
	-- Calculate the density required to achieve the desired mass
	local density = desiredMass / currentMass
	-- Set the custom physical properties with desired density
	handle.CustomPhysicalProperties = PhysicalProperties.new(density, 0.3, 1, 0.3, 1)
	-- Calculate the direction and initial position for the throw
	local throwDirection = (mouse.Hit.p - humanoidRootPart.Position).unit
	local throwPosition = humanoidRootPart.Position + Vector3.new(0, 2, 0) -- Adjust the throw start position
	local throwSpeed = 45  -- Speed of the throw
	
	-- Calculate the initial velocity based on direction and speed
	local initialVelocity = throwDirection * throwSpeed + Vector3.new(0, 30, 0)  -- Add vertical component
	
	-- Fire the event to the server to handle the actual throw
	throwEvent:FireServer(tool, throwPosition, initialVelocity)
end

tool.Activated:Connect(onActivated)

The setup of the tool in the explorer (Starterpack) is:

Tool

  • ToolScript
  • Handle

That’s it. Nothing inside the handle or anywhere else.

The tool has CanCollide and CanTouch both True.
Massless is also True although it was false initially, so changing that hasn’t helped.
Nothing else is falling through the Terrain.

So why does it disappear through the floor???

Please provide a picture of the tool and its children in the explorer

It could have something to do with your handle being a MeshPart. Roblox tends to have issues handling collisions with MeshParts. Try this:
Insert a Part into the tool and make it the same size as your Handle and make it transparent. Weld it to the handle and make sure cancollide is true. This should make a “fake” collision box for your MeshPart.

2 Likes

Brilliant!
Thank you so much, it was driving me crazy trying to figure that out!

No problem! Glad I could help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.