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

How would I make this function fire off only when the tool is selected?

Asked by 8 years ago

This script works just fine, but I can't figure out how to make it into a proper tool! Please help! Thank you!!

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Players = game.Players:GetChildren()
local contraband = player:WaitForChild('Illegal').Contraband
tool = script.Parent


function SearchPerson()
    if mouse.Target ~= nil then
    for _,v in pairs(game.Players:GetChildren()) do
        if mouse.Target.Parent.Name == v.Name then
        local selectedPlayer = v
        local character = selectedPlayer.Character
        player.PlayerGui.Searching.Frame.Visible =  true
        wait (5)
        player.PlayerGui.Searching.Frame.Visible =  false
        if v.Illegal.Contraband.Value == 1 then
        player.PlayerGui.BadGuy.Frame.Visible =  true
        else
        player.PlayerGui.GoodGuy.Frame.Visible = true




            print ('This person is in players')
            print ("Searching " ..v.Name .. " for illegal substances")
        end
    end
    end
end
end


mouse.Button1Down:connect(SearchPerson)
1
What is the actual problem? LisaF854 93 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

roblox tools have a .Equipped event Equipped

0
Thank you! I figured it out. marsupicide 60 — 8y
Ad

Answer this question