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

CFrame Basic Problem Weirdness Dilemma Pls Help?

The script

wait(1)
local parts = script.Parent.Drawer:GetChildren("Part")
for i = 1,100,0.1 do
	wait()
	parts.CFrame = parts.CFrame + Vector3.new(0,0,0.5)
end

The error

11:20:45.222 - Workspace.Model.Script:5: bad argument #1 to '?' (Vector3 expected, got nil)
11:20:45.223 - Stack Begin
11:20:45.224 - Script 'Workspace.Model.Script', Line 5
11:20:45.224 - Stack End

2 comments

0

Stacks beginning and ending are not errors.

0

Unless you have an answer pls don't reply or answer, ty.

1 answer

Never mind I figured it out with my old script from 2 years ago lol.

local bool = false
local activated = 0 -- 0 is closed 1 is open
local function close()
	local jaw = script.Parent.Jaw:GetChildren()
	local teeth = script.Parent.Teeth:GetChildren()
	for a,b in pairs (jaw) do
		if b:IsA('UnionOperation') or b:IsA('Part') then
			b.CFrame = b.CFram
e * CFrame.new(0,-0.1,0)
		end
	end
	for c,d in pairs (teeth) do
		if d:IsA('UnionOperation') or d:IsA('Part') then
			d.CFrame = d.CFrame * CFrame.new(0,-0.1,0)
		end
	end
end

local function open()
	local jaw = script.Parent.Jaw:GetChildren()
	local teeth = script.Parent.Teeth:GetChildren()
	for a,b in pairs (jaw) do
		if b:IsA('UnionOperation') or b:IsA('Part') then
			b.CFrame = b.CFrame * CFrame.new(0,0.1,0)
		end
	end
	for c,d in pairs (teeth) do
		if d:IsA('UnionOperation') or d:IsA('Part') then
			d.CFrame = d.CFrame * CFrame.new(0,0.1,0)
		end
	end
end

script.Parent.Activate.ClickDetector.MouseClick:connect(function()
	if bool == false then
		bool = true
		if activated == 0 then
			for x = 50,0,-0.1 do
				wait()
				open()
			end
		else
			for x = 50,0,-0.1 do
				wait()
				close()
			end
		end
		bool = false
	end
end)

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