Hey!
I need help!
I wanted to make a tool with a handle. If you click with it, you clone the handle and drop it 5 studs infront of your rootpart.
If you click again, the handle destroys and is back in your hand. How would i do that?
I tried it a few times by using clicked qnd activated events, but it isnt working.
--// Var //--
local Player = game:GetService("Players").LocalPlayer --// getting the localplayer
local character = Player.Character or Player.CharacterAdded:Wait() --// Waiting for character of the localPlayer
local Tool = script.Parent --// Getting the tool
local IsDroped = false --// debounce
local Clone_Drop_Part
--// function //--
function drop_The_part() --// function for the part to drop
if not IsDroped then --// checking if it is not Droped
IsDroped = true --// Puting the debounce to be true (Droped = true)
Clone_Drop_Part = Tool.Handle:Clone() --// Cloning the Part (Handle)
--// Chaning The CFrame (Position) of the Cloned Part to be 5 studs infront of your HumanoidRootPart //--
Clone_Drop_Part.CFrame = character:WaitForChild("HumanoidRootPart").CFrame + character:WaitForChild("HumanoidRootPart").CFrame.LookVector * Vector3.new(5, 0, 5)
--// Put the Handle Part to be invisible (Transparency = 1)
Tool.Handle.Transparency = 1
--// Put the Cloned Part CanCollide = true
Clone_Drop_Part.CanCollide = true
--// Put the Parent of the Cloned Part to workspace
Clone_Drop_Part.Parent = workspace
else
IsDroped = false --// Puting the debounce to be false (Droped = false)
if Clone_Drop_Part then --// checking if there is a Part(Cloned) in the workspace
Tool.Handle.Transparency = 0 --// Put the Handle Part to be visible (Transparency = 0)
Clone_Drop_Part:Destroy() --// Destroing the Part(Cloned) from the workspace
end
end
end
--// event //--
Tool.Activated:Connect(drop_The_part) --// Player Click on the tool