Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved myself] Tool falls trough the ground?

Asked by 5 years ago
Edited 5 years ago

Basicly, I wanna know how to make the tools parts CanCollide = false if a player got it in his hands. When the tool gets dropped and lays on the ground, i want it to make it completly CanCollide = true. Is there a way to do this? Or is there already a function in roblox for this? Thanks :) Side Note: Because when i would CanCollide = true all parts it would be weird when i hit some other parts or players.

0
Tool.Equipped User#24403 69 — 5y
0
Thats not telling me much. Paintertable 171 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You can use Equipped to tell you when the tool is taken out of the backpack and you can use Unequipped to tell you when it is put back into the backpack. I made a server script below which is assuming there is a part inside called "Handle" and that the server script is inside the tool itself. You could do the same thing with a local script but you would have to fire a remote event and then have a server script do the collisions. If you wanted to have multiple parts inside a tool be CanCollided you should be able to just add a for loop with GetChildren for it to work ;)

local tool = script.Parent
local part = tool:WaitForChild("Handle")

tool.Equipped:Connect(function()
    part.CanCollide = false 
    print("Equipped and removed collisions!")
end)

tool.Unequipped:Connect(function()
    part.CanCollide = true
    print("Equipped and added collisions!")
end)
Ad

Answer this question