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

Could anyone helpfully give me some helpful efficiency tips like a nice and helpful person? [closed]

Asked by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Thanks to those who are being truly helpful. I have spent a long time writing this Script and I would nicely ask for those who are truly here to help . Thanks again!!

function findObject(instance,object,handle)
    repeat wait() until instance
    local itemDecendants = instance:GetDescendants()
    for _,object in ipairs(itemDecendants) do
        if (object:IsA(object) and object.Parent:IsA(instance.ClassName) and object:IsDescendantOf(instance)) and object.Name == handle then
            print(object:GetFullName()); return object
        end
    end
end

local localPlayer = game:GetService("Players").LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:wait()
local cursor = localPlayer:GetMouse(); local cursorPoint = cursor.Target
local clickDetector
local checkForItem = true
local foundItem = false
local item_
local item

spawn(function()
    while wait(.5) do
        while (checkForItem) do
            cursorPoint = cursor.Target
            pcall(function()
                print(cursorPoint)
                if cursorPoint:IsA("BasePart") then --//Set to 'Tool'.
                    print("BasePart - '"..cursorPoint.Name.."'")
                    for _, descendant in ipairs(cursorPoint:GetDescendants()) do
                        if findObject(descendant, "BoolValue", "ItemTag") then print("foundItem")
                            item_ = cursorPoint.Name
                            item = workspace:WaitForChild(item_)
                            clickDetector = findObject(item, "ClickDetector", "ClickDetector")
                            foundItem = true
                            checkForItem = false
                        end
                    end
                end
            end)
        wait(.5)
        end
        cursorPoint = cursor.Target
        if item then
            if (cursorPoint ~= item and checkForItem ~= true) then
                item = nil
                checkForItem = true
                foundItem = false
            end
        end
    end
end)

repeat wait() until foundItem

pcall(function()
   clickDetector.MouseClick:Connect(function()
      print("Hott")
   end)
end)

If anyone cannot understand where I'm getting at here, please just tell me and I'll happily explain it like the helpful person I am

0
so does it work? GoldAngelInDisguise 297 — 5y
0
Yes Ziffixture 6913 — 5y
0
I was just asking if anyone could nicely help me improve my work Ziffixture 6913 — 5y
0
...:wait() is deprecated. use ...:Wait() also while wait() do end is not a good way, use while true do wait() end yHasteeD 1819 — 5y
View all comments (6 more)
0
This question is primarily opinion based. It is up to whoever answers your question how to make it more efficient. They could be totally wrong. User#24403 69 — 5y
0
I can tell for myself thank you, I don't care Ziffixture 6913 — 5y
0
Okay, I'll give that a spin Ziffixture 6913 — 5y
0
Your question could get closed. User#24403 69 — 5y
0
Shhhh Ziffixture 6913 — 5y
0
no User#24403 69 — 5y

Closed as Primarily Opinion-Based by User#24403, Gey4Jesus69, lunatic5, zblox164, SummerEquinox, and yHasteeD

This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.

Why was this question closed?