Unable to cast Vector3 to float

Well this line of code begun anoying me, and i have no idea how to fix it

  1. What do you want to achieve?

Well trying to remove this bug lol

  1. What is the issue?

Well i tryed useing the Shperecast function and well it’s compleatly unsucsesfull

  1. What solutions have you tried so far?

Tryed to find any soliutions on google but no results and then tryed on the discord, well no result there ;-;

The Code (if you want more i can send full script, but it’s 85 lines of code and it’s painfull to watch) the error is on Local castdown = …

for _, i in pairs(theradius:GetChildren()) do
				local castdown = workspace:Spherecast(Vector3.new(i.Position.X, i.Position.Y, i.Position.Z), Vector3.new(i.Position.X, i.Position.Y, i.Position.Z), Vector3.new(i.Position.x, i.Position.Y - 10, i.Position.Z))
				if castdown == nil then
					i.Name = "Totaly Empty"
					i.BrickColor = BrickColor.Red()
				end
1 Like

Second argument for Spherecast requires a number, you’re passing a vector3.

2 Likes

There’s a typo in your code, instead of x it should be X.

Also as the above reply mentions the second parameter of Spherecast is a number/float that describes the radius of the sphere of the cast, not a vector. If you’re trying to cast from the positional vector all the way to the second vector in a sphere-like way then you can calculate the radius with this equation:

local offset = 0 --in case you want the radius to be a bit larger
local radius = (v1-v2).Magnitude+offset --where v1 and v2 your 2 vectors
1 Like

Oh pft, probably i was quiet tierd and havent seen this problem lol, well other lads wount suffer as much as me lol

1 Like

i just realised that it’s a BALL soo yea, and about x and X, if it’s working that’s good lol, but thanks for some info

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.