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

connect is not a valid member of ClickDetector?

Asked by
Peeshavee 226 Moderation Voter
7 years ago

So, I'm working on this CFrame script, where a part starts at one position and goes through an another brick, which is in a new position. Here's the script:

local cf = game.Workspace.cfrme
local db = false


function move(hit)
    local human = hit.Parent:FindFirstChild(hit)
    if not db then
        if human then

            db = true

            for i = 3, 1, -0.1 do
            cf.CFrame = CFrame.new(Vector3.new(-5.8,6.7,68))
            cf.CFrame = CFrame.new(Vector3.new(-5.8,i,68))
            end

            db = false

        end 
    end
end

cf.ClickDetector.MouseClick:Connect(move)

When I click the brick, nothing happens, and output says "Connect is not a valid member of ClickDetector". What have I done wrong here? All help is appreciated!

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

remove :FindFirstChild(hit) from line 6, it worked for me when i tested this script in studio

local human = hit.Parent:FindFirstChild(hit)

local human = hit.Parent

0
Oh my gosh. I'm so stupid. I put hit in the brackets instead of humanoid. Wow. Thanks. Peeshavee 226 — 7y
0
no problem :P it happens RobloxianDestory 262 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

"Connect" is supposed to be "connect" A common mistake

cf.ClickDetector.MouseClick:Connect(move)

cf.ClickDetector.MouseClick:connect(move)
0
Even when I changed that, it still doesn't work. Any other help? Peeshavee 226 — 7y

Answer this question