Attempt to index number with 'Config' error

I making TD game
At first, there was no such error, but apparently, after updating the studio or new scripts, it appeared, tried to rewrite, etc. but it does not want to disappear, please help
2. It appears after the spawning tower, config (configuration object) in tower file,Range is intValue
Screenshot:

  1. I looked for solving in Developer Hub but not find

Script:

local function CreateRangeCircle(tower, placeholder)
	
	local range = tower.Config.Range.Value
	local height = (tower.PrimaryPart.Size.Y / 2) + tower.Humanoid.HipHeight
	local offset = CFrame.new(0, -height, 0)
	
	local p = Instance.new("Part")
	p.Name = "Range"
	p.Shape = Enum.PartType.Cylinder
	p.Material = Enum.Material.Neon
	p.Transparency = 0.9
	p.Size = Vector3.new(2, range * 2, range * 2)
	p.TopSurface = Enum.SurfaceType.Smooth
	p.CFrame = tower.PrimaryPart.CFrame * offset * CFrame.Angles(0, 0, math.rad(90))
	p.CanCollide = false
	
	if placeholder then
		p.Anchored = false
		local weld = Instance.new("WeldConstraint")
		weld.Part0 = p
		weld.Part1 = tower.PrimaryPart
		weld.Parent = p
		p.Parent = tower
	else
		p.Anchored = true
		p.Parent =workspace.Camera
	end
	
end

Thanks

The error is saying the following:

tower is a number value.

Make sure when you call the function that the first parameter is actually an object instead of a number.

I have now tried to replace the tower with towers (local towers = ReplicatedStorage:Wait For Child(“Towers”) Towers-folder with tower models) but the error remained

Also i tried to replace with folder name but error remained too

Where are you calling the functino from?

The script is in the starter gui (if that’s what you meant)

Where are you calling CreateRangeCircle(), as in - what is the before and after code

before is mouse raycast function
after is create of CreateRangeCircle

local function RemovePlaceholderTower()
	if towerToSpawn then
		towerToSpawn:Destroy()
		towerToSpawn = nil
		rotation = 0
	end
end

local function AddPlaceholderTower(name)
	
	local towerExists = towers:FindFirstChild(name)
	if towerExists then
		RemovePlaceholderTower()
		towerToSpawn = towerExists:Clone()
		towerToSpawn.Parent = workspace.Towers
		
		CreateRangeCircle(towerToSpawn, true)
		
		for i, object in ipairs(towerToSpawn:GetDescendants()) do
			if object:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(object, "Tower")
				if object.Name ~= "Range" then
					object.Material = Enum.Material.ForceField
					object.Transparency = 0.3
				end
			end
		end
	end
end

local function ColorPlaceholderTower(color)
	for i, object in ipairs(towerToSpawn:GetDescendants()) do
		if object:IsA("BasePart") then
			object.Color = color
		end
	end
end

I’m bad at scripting, most of it was written using tutorials

If this come appeared so the script is not the problem.
Try this on top of local range = tower.Config.Range.Value
And make a screenshot
I guess is come from the Explorer

local function CreateRangeCircle(tower, placeholder)
      print(tower,typeof(tower))
      print(tower,typeof(Config))
      print(tower,typeof(Config.Range))
      print(tower,typeof(Config.Range.Value))

One problem, new error attempt to index nil with ‘Range’
Config dont have local line

work only first and second line

There are 4 lines of print appears right?
Can you show them

after message an error appears

my bad i have write errors can you test this and replace with other thing:
I put Config instead tower.Config

local function CreateRangeCircle(tower, placeholder)
	print(tower,typeof(tower))
	print(tower,typeof(tower.Config))
	print(tower,typeof(tower.Config.Range))
	print(tower,typeof(tower.Config.Range.Value))

yep,now working (Newie is tower name)

but error

I think i have the solution in the original script:
Replace tower.Config.Range.Value to tower.Config.Range

dont work

The issue is that the parameter tower is a number, not an object.

Basically look where you called this from and fix the parameter you send through, because the parameter type is incorrect, it has to be an object not a number.

put three backticks the button under your escape key