Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

CurrentCamera Vector3 Expected, got number) ?

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

✓ Accepted answer

(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.

1 comment

0

Worked! Thank you so much.

This discussion is preserved as it was. New answers, comments, and votes are closed.