I'm trying to send a Vector3 to a function to use for in a force value. But, when I call the function with a Vector3 parameter I get the error: Unable to cast Vector3 to token
local UIS = game:GetService('UserInputService')
local myCharacter = script.Parent
local myBody = myCharacter:WaitForChild('HumanoidRootPart')
local myVForce = Instance.new('VectorForce',myBody) -- Create a vector force obj in chest piece
myVForce.Attachment0 = myBody.RootRigAttachment
myVForce.Force = Vector3.new(0,0,0)
local dodgeKeys = {
A = Vector3.new(-1500,0,0),
D = Vector3.new(1500,0,0),
S = Vector3.new(0,0,-1500),
W = Vector3.new(0,0,1500)
}
-- Define Functions
local function getMass()
local M = 0
for i,Part in pairs(myCharacter:GetDescendants()) do
if (Part:IsA('BasePart') and not Part.Massless) then
M = M + Part.Mass
end
end
return M
end
local function playerDodge(DodgeA)
print('Dodge Called')
local M = getMass()
local F = M*DodgeA -- F=ma
myVForce.Force = F
wait(0.2)
myVForce.Force = Vector3.new(0,0,0)
end
-- Interaction
UIS.InputBegan:Connect(function(key,i)
print("Key Pressed")
if (key.KeyCode == Enum.KeyCode.F) then
local dodgeForce = Vector3.new(0,0,0)
for Key,Vec in pairs(dodgeKeys) do
if UIS:IsKeyDown(dodgeKeys[Key]) then
dodgeForce = dodgeForce + dodgeKeys[Key]
end
end
playerDodge(dodgeForce)
end
end)
The error starts when I press the F and any of the WASD keys. Error msg says line 47. I'm really not sure what's going on here :\ Any help appreciated. How can I send the dodgeForce Vector3 to the playerDodge function?

1 comment
omg thanks :) Can't believe I didn't see that