I have been working on a Tower Defense game, and when you are about to place a tower, it shows it range/radius and the same goes for when you place it and click it.
However, it does not work correctly, the orientation is extremely off, and the radius part isn’t even positioned correctly (it is supposed to be at the ground). (The tower’s HipHeight is 0 so it doesn’t float just in case however when I tried setting it to 2 it still didn’t work)
Any help is appreciated.
Code from the range part taken from GnomeCode’s Tower Defense Series:
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.BottomSurface = Enum.SurfaceType.Smooth
p.CFrame = tower.PrimaryPart.CFrame * offset * CFrame.Angles(0, 0, math.rad(90))
p.CanCollide = false
p.Anchored = true
p.Parent = workspace.Camera
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