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

Why does it say: Vector3 expected, got CFrame?

Asked by 4 years ago
Edited 4 years ago

Error:

11:47:03.881 - Workspace.Model.Main.Script:57: bad argument #2 to '?' (Vector3 expected, got CFrame)
11:47:03.881 - Stack Begin
11:47:03.883 - Script 'Workspace.Model.Main.Script', Line 57
11:47:03.883 - Stack End

Code:

-- Services
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

-- Variables 
local Heli = script.Parent.Parent
local GyroScope = script.Parent
local Thrust = GyroScope:FindFirstChild("BodyThrust")
--local Reaction = GyroScope:FindFirstChild("BodyReaction")
local Force = GyroScope:FindFirstChild("BodyForce")

-- Physics Variables
local m = GyroScope:GetMass()
local g =  workspace.Gravity
local cf = CFrame.new()
local vector = Vector3.new()

-- Other 
local enum = Enum.KeyCode

-- Movement Table
local Movement = {[tostring(enum.T)] = CFrame.Angles(0, 0, math.rad(20)), 
                  [tostring(enum.F)] = CFrame.Angles(math.rad(10), 0, 0),    
                  [tostring(enum.H)] = CFrame.Angles(math.rad(-10), 0, 0),
                  [tostring(enum.G)] = CFrame.Angles(0, 0, math.rad(-20)),
                  [tostring(enum.Y)] = Vector3.new(0, 100, 0),
                  [tostring(enum.R)] = Vector3.new(0, -100, 0)
                 }
-- Constants
local Keys = {[tostring(enum.T)] = cf,
              [tostring(enum.F)] = cf,
              [tostring(enum.G)] = cf,
              [tostring(enum.H)] = cf,
              [tostring(enum.Y)] = vector,
              [tostring(enum.R)] = vector
             }

-- The loop 
game:GetService("RunService").Stepped:Connect(function()

    local W = Keys[tostring(enum.T)] 
    local A = Keys[tostring(enum.F)] 
    local D = Keys[tostring(enum.G)] 
    local S = Keys[tostring(enum.H)] 
    local Y = Keys[tostring(enum.Y)] 
    local R = Keys[tostring(enum.R)] 


    -- Gravity work
    Thrust.Force = Vector3.new(0, 2*m*g, 0)
--  Reaction.Force = -Vector3.new(0, m*g, 0)

    GyroScope.Velocity = GyroScope.Velocity - GyroScope.Velocity/10

    -- adding Force values
    Force.Force = R + Y
    GyroScope.CFrame = W * A * S * D
end)

UserInputService.InputBegan:Connect(function(input)

    Keys[tostring(input.KeyCode)] = Movement[tostring(input.KeyCode)]

end)

UserInputService.InputEnded:Connect(function(input)

    Keys[tostring(input.KeyCode)] = cf 

end)

Error line:

Line 56: Force.Force = R + Y
0
can you print typeof(R), typeof(Y)? royaltoe 5144 — 4y
0
force is expecting a vector3 value royaltoe 5144 — 4y

Answer this question