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

How do I make a script that activates a tool?

Asked by 1 year ago

For example, the sword will slash when I click? So how do I make a local script that will slash using click for me on client-sided?

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

To slash a tool, you create a StringValue inside a tool. The StringValue must be named "toolanim". Then set the value to "Slash". And to slash the tool by clicking, simply use Tool.Activated. Tool.Activated fires when you click the screen while holding the tool. Also don't forget that your tool has a handle and RequiresHandle is set to true, otherwise it won't work. Put a script inside the tool and the script should look like this:

local tool = script.Parent
local debounce = false

tool.Activated:Connect(function()
    if not debounce then
        debounce = true
        local value = Instance.new("StringValue", tool)
        value.Name = "toolanim"
        value.Value = "Slash"
        task.wait(1)
        debounce = false
    end
end)

You can also remove debounce if you want. Debounce is like a cooldown when you activate the tool. Hope this helps! #LearnSomethingNewToday

Ad

Answer this question