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

how do you detect if player clicks a model with a tool?

Asked by 2 years ago

im trying to make a tool named shovel and when it clicks on a model, inside of the model a part change size, im trying to detect it but mine just breaks. How do you accurately detect it?

1 answer

Log in to vote
0
Answered by 2 years ago

If player equips tool, this appears at his model. Here is code

ClickDetect = YourWayToClickDetector --There your way to click detector
function Click()
    for _, i in pairs(script.Parent:GetChildren()) do --Starts searching
        local Name = tostring(i.Name)
        if Name == "Trowel" then --Checks that player equipped tool, put there your tool name
            -- Your Code there
        end
    end
end
ClickDetect:Connect(Click)
0
what do you mean by "there your way to click detector? MOJANGcreator091 60 — 2y
0
You need to create a instance named "Click Detector" and parent it to a part you need to click. you can read about it there: https://developer.roblox.com/en-us/api-reference/class/ClickDetector AgentViteC 58 — 2y
Ad

Answer this question