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

CurrentCamera Vector3 Expected, got number) ?

Asked by 5 years ago

Was working on a location handler when I got this error involving vector3 expected and got numbers

local plr = game.Players.LocalPlayer
local char = plr.Character
local LocationText = script.Parent
local Frame = LocationText.Parent
local Gui = Frame.Parent
local LastLocation

local SuburbMsg = game.workspace.SuburbMSG
local City = game.workspace.CityMSG


char.Humanoid.Changed:Connect(function()
    if workspace.CurrentCamera.CFrame.p - SuburbMsg.Position.Magnitude < 15 and LastLocation ~= "'Suburb'" then
        LocationText.Text = "'Suburb'"
        LastLocation = "'Suburb'"
        LocationText.TextTransparency = 1
        LocationText.TextStrokeTransparency = 1
        LocationText.TextStrokeColor3 = Color3.new(0, 2, 97)

1 answer

Log in to vote
1
Answered by 5 years ago

(Tip: it's good to let us know what line an error occurs on so we don't have to guess, though there's only one possibility in this case.)

That error means that Roblox is expecting a Vector3 and whatever you gave it was just a number. For instance, if you do part.Position = 3, you'd get that error.

The problem here is line 13, where you take the Magnitude of the SuburbMsg.Position vector instead of the magnitude of the whole expression. You want (workspace.CurrentCamera.CFrame.p - SuburbMsg.Position).Magnitude. Roblox didn't define "Vector3 - number", which is why it complained about expecting the Vector3.

0
Worked! Thank you so much. IrishStukov 20 — 5y
Ad

Answer this question