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

CFrame Basic Problem Weirdness Dilemma Pls Help?

Asked by
lysandr 49
7 years ago

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
0
Stacks beginning and ending are not errors. hiimgoodpack 2009 — 7y
0
Unless you have an answer pls don't reply or answer, ty. lysandr 49 — 7y

1 answer

Log in to vote
0
Answered by
lysandr 49
7 years ago
Edited 7 years ago

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)
Ad

Answer this question