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

How can I run a function anytime a player equips a tool?

Asked by 7 years ago

I made a script that toggles a run for the character. I want the character to be UNABLE to equip tools while running = true. How can I do this?

0
how fast would the player be going while running? I am asking so I can make the script. NegativeNil 0 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Well the function for equipping tools is: .Equipped:connect(function() And make sure that you change running from a variable to a bool value so the scripts can communicate. Then, put a local script in the tool and write this.

local p = game.Players.LocalPlayer
local pname = p.Name

function equip(equipped)
    if --Put location of the running bool value here--.Value == true then
        for i, v in pairs(game.Workspace:GetChildren()) do
        if pname == v.Name then
        script.Parent.Parent = p.Backpack
    end
end

script.Parent.Equipped(equip)
Ad

Answer this question