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

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

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)

1 comment

0

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

1 answer

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.

5 comments

0

Can you explain a bit more, i dont really get it.

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".

0

Got it, thanks!

0

Hey click "Accept Answer" beside my question to mark your question as answered.

0

Hey click "Accept Answer" beside my answer to mark your question as answered.

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