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

SCP Script door error «Vector3 expected, got CFrame» how to fix?

I'm not really good in CFrame so can you help me for fix this?:/

15:25:48.386 - Workspace.Gate.Script:8: bad argument #2 to '?' (Vector3 expected, got CFrame)

deboulse = false

script.Parent.Button.ClickDetector.MouseClick:connect(function(player)
	if deboulse == false then
		deboulse = 2
		print(player.Name.." open door")
		for index, door in pairs(script.Parent.Parts:GetChildren()) do
			for i = 0,100 do
				door.CFrame = door.CFrame-CFrame.new(0,0,-4)
				wait()
			end
		end
		for index, light in pairs(script.Parent.lights:GetChildren()) do
			light.Color = BrickColor.new("Really red")
		end
		script.Parent.lights.BrickColor = BrickColor.new("Really red")
		deboulse = true
	elseif deboulse == true then
		deboulse = 2
		print(player.Name.." close door")
		for index, door in pairs(script.Parent.Parts:GetChildren()) do
			for i = 0,100 do
				door.CFrame = door.CFrame-CFrame.new(0,0,4)
				wait()
			end
		end
		for index, light in pairs(script.Parent.lights:GetChildren()) do
			light.Color = BrickColor.new("Institutional white")
		end
		script.Parent.lights.BrickColor = BrickColor.new("Institutional white")
		deboulse = false
	end
end)

Explorer: https://gyazo.com/ebc068f3ba1378368b4869dab81c79a6

1 answer

✓ Accepted answer

You can't add and subtract CFrames. CFrames are really just matrices, which don't have a standardized form of addition or subtraction.

It sounds like you just want to translate the CFrame. Replace CFrame.new(x, y, z) with Vector3.new(x, y, z). It comes up on lines 9 and 23 in the code you posted.

The operators you can use with CFrames are listed here.

2 comments

0

Thanks you but now the door rotate? Why? https://gyazo.com/dcd7ffa122f8fe66914329f78b551aa1

0

It shouldn't rotate from this change, there must be some other problem. You'll have to post update code in a new question.

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