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

Attempt to call global Vector3? [FIXED]

Asked by 4 years ago
Edited 4 years ago

Hello,

Recently I have been trying to make a door which slides up and down when you press a button, I am trying to get it so the script looks for the position of the door and if it is equal to 190.253, 8.125, 67.725, then make the door open by sliding up. But on the 6th line, it comes up with the error of

Workspace.Model.LeftDoor.Button.Script:6: attempt to call global 'Vector3' (a table value)

local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor
local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor
local Sound = script.Parent.Sound

script.Parent.ClickDetector.MouseClick:connect (function()
    if LeftDoor.CFrame == (Vector3(190.253, 8.125, 67.725)) then
        for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3(0,1,0))
            wait()
        end
            Sound.Playing = false
            Sound.Playing = true
    else if LeftDoor.Position == (Vector3(190.253, 22.125, 67.725)) then
            for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3(0,1,0))
            wait()
      end
            Sound.Playing = false
            Sound.Playing = true
    end
  end
end)

Does anybody know a way of fixing this?

0
You should do Vector3.new instead of Vector3. Maybe that is your problem... Block_manvn 395 — 4y
0
So I would do something like `if LeftDoor.CFrame == (Vector3.new(190.253, 8.125, 67.725)) then`? Because that didn't work DiamondRules01 56 — 4y
0
uh no, if LeftDoor.CFrame == Vector3.new(--Position--) Nguyenlegiahung 1091 — 4y
0
I hope it would work Nguyenlegiahung 1091 — 4y

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

This should work

local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor
local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor
local Sound = script.Parent.Sound

script.Parent.ClickDetector.MouseClick:connect (function()
    if LeftDoor.CFrame == Vector3(190.253, 8.125, 67.725)) then
        for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3(0,1,0))
            wait()
        end
            Sound.Playing = false
            Sound.Playing = true
    else if LeftDoor.Position == Vector3.new(190.253, 22.125, 67.725)) then
            for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3(0,1,0))
            wait()
      end
            Sound.Playing = false
            Sound.Playing = true
    end
  end
end)

0
Same error, also an error with ) on like 06 and 13 which I removed, yet same error. 15:25:57.198 - Workspace.Model.LeftDoor.Button.Script:6: attempt to call global 'Vector3' (a table value) DiamondRules01 56 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I've created a new script for it and it works, kind of.

local LeftDoor = script.Parent.Parent.Parent.LeftOfficeDoor
local RightDoor = script.Parent.Parent.Parent.RightOfficeDoor
local Sound = script.Parent.Sound
local debounce = false
local door = false

script.Parent.ClickDetector.MouseClick:connect(function()
    if not debounce then debounce = true
    if not door then door = true
            Sound.Playing = false
            Sound.Playing = true
        for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position + Vector3.new(0,1,0))
            wait()
        end
               debounce = false
    else if door then door = false
            Sound.Playing = false
            Sound.Playing = true
            for i = 1,14 do
            LeftDoor.CFrame = CFrame.new(LeftDoor.Position - Vector3.new(0,1,0))
            wait()
end
        debounce = false
    end
  end
end
end)

Its a bit more but it works

Answer this question