Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to stop a useless click on my tool?

I really didn't know how to explain this in one line of a question but its not that complex of a problem.

Basically i have a tool which drops the block you have picked up and then removes itself, when it does that it still requires clicking 1 more time to allow you to click elsewhere (if that makes sense), For example if i don't click for the second time i cant click clickdetectors.

This is my first time scripting a tool so sorry if its bad.

local Tool = script.Parent
 
Tool.Equipped:Connect(function(Mouse)
	Mouse.Button1Down:Connect(function()
		game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
		script.Parent.Handle.ClickDetector.MaxActivationDistance = 32
		script.Parent.Handle.Name = "Block"
		script.Parent.Block.Size = Vector3.new(2,2,2)
		script.Parent.Block.CanCollide = true
		script.Parent.Block.Parent = workspace
		script.Parent:Destroy()
	end)
end)

1 answer

✓ Accepted answer

Hi!

To stop this "useless click", you have to use a Tool function called Activate(). Here's the fixed script:

local Tool = script.Parent

Tool.Activated:Connect(function(Mouse)
    game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
    script.Parent.Handle.ClickDetector.MaxActivationDistance = 32
    script.Parent.Handle.Name = "Block"
    script.Parent.Block.Size = Vector3.new(2,2,2)
    script.Parent.Block.CanCollide = true
    script.Parent.Block.Parent = workspace
    script.Parent:Destroy()
end)

Feel free to ask me on this answer if you need any help.

Sincerely, Ziruken

2 comments

1

Ah thank you, It works perfectly!

0

use variables for "script.Parent.Handle", "script.Parent.Block"

This discussion is preserved as it was. New answers, comments, and votes are closed.