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

CFrame is not a valid member of ClickDetector "Workspace.CodeDoor.Door.Button.ClickDetector"?

Asked by 4 years ago

Im not sure what went wrong. Im trying to move the button along with the sliding door with CFrame. The button has a click detector in it.

Here's the script:

--Waiting for objects to load local Configuration = script.Parent:WaitForChild("Configuration") local Code = Configuration:WaitForChild("Code") local TimeOpen = Configuration:WaitForChild("TimeOpen") local SlidingTime = Configuration:WaitForChild("SlidingTime") local Height = Configuration:WaitForChild("Height") local Button = script.Parent.Door:WaitForChild("Button"):WaitForChild("ClickDetector") local Door = script.Parent:WaitForChild("Door") --Tweening local tweenService = game:GetService("TweenService") local tweenInfo = TweenInfo.new(SlidingTime.Value,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0) --Other variables local open = false

--Fuction that plays when we click the button. Button.MouseClick:Connect(function(player) local newcode = game.ReplicatedStorage:WaitForChild("CodeDoor"):InvokeClient(player) --we invoke the players client and wait until they return the code

if newcode == Code.Value and open == false then
    print('correct')
    open = true
    local goal1 = {CFrame = Door.CFrame + Vector3.new(-3,Height.Value,0)}   --CFrame of the door when it moves up, used for tween1
    local goal2 = {CFrame = Door.CFrame}                        --Devault CFrame for the door, used for tween2
    local goal3 = {CFrame = Button.CFrame + Vector3.new(-3,Height.Value,0)}
    local goal4 = {CFrame = Button.CFrame}  
    local tween1 = tweenService:Create(Door,tweenInfo,goal1)    --opening tween
    local tween2 = tweenService:Create(Door,tweenInfo,goal2)    --closing tween
    local tween3 = tweenService:Create(Button,tweenInfo,goal3)
    local tween4 = tweenService:Create(Button,tweenInfo,goal4)
                    --Light (part) color changes
            --PointLight color changes (optional, disabled by default)
    tween1:Play()                                               --The door opens because we play the opening tween
    wait(TimeOpen.Value)
    tween2:Play()                                               --The door closes because we tween the doors CFrame back to normal
    wait(SlidingTime.Value)                                 
                    --Light (part) color changes
        --PointLight color changes (optional, disabled by default)
    open = false
else        --If the code is not correct, we just print "incorrect"
    print('incorrect') 
end

end)

0
Hey!! Click accept answer on the side of my answer to view your question as answered. It will help me a lot too. Shounak123 461 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

You have to move the button, not the Clickdetector itself. Move the button's CFrame and it will work fine. The clickdetector will move with the button.

0
Can you explain a bit more, i dont really get it. krxtenaa 11 — 4y
1
What he is trying to say is that you must have used the incorrect variables for either Door or Button (line 4, 5, 6, 7). It's possible that you specified ClickDetector in the variables, and not Door and Button, hence the error, since ClickDetector doesn't have a property named "CFrame". MysteriousCeburek 27 — 4y
0
Got it, thanks! krxtenaa 11 — 4y
0
Hey click "Accept Answer" beside my question to mark your question as answered. Shounak123 461 — 3y
0
Hey click "Accept Answer" beside my answer to mark your question as answered. Shounak123 461 — 3y
Ad

Answer this question