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

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

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 comment

1

What is the actual problem?

1 answer

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