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

How to stop a useless click on my tool?

Asked by
PastDays 108
4 years ago

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

Log in to vote
1
Answered by
Ziruken 139
4 years ago

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

1
Ah thank you, It works perfectly! PastDays 108 — 4y
0
use variables for "script.Parent.Handle", "script.Parent.Block" bhqpping 80 — 4y
Ad

Answer this question