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

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

Asked by 8 years ago
Edited 8 years ago

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

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

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.

0
Thanks you but now the door rotate? Why? https://gyazo.com/dcd7ffa122f8fe66914329f78b551aa1 NiniBlackJackQc 1562 — 8y
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. script_help 74 — 8y
Ad

Answer this question