-
What do you want to achieve? im trying to make a script that makes the parts inside boundaries folder change transparency
-
What is the issue? doesnt work and i get a error saying
Attempt to index nil with "Boundaries"
when placeholdertower -
What solutions have you tried so far? i looked in dev forum but i guess nothing helped me, i dont know what to do
(LOCAL SCRIPT IN STARTERGUI AND SCREEN GUI)
local map = workspace.Map:FindFirstChildOfClass("Folder")
local function mapBoundaries(transparency)
for _, part in ipairs(map.Boundaries:GetDescendants()) do
if part:IsA("BasePart") then
part.Transparency = transparency
end
end
end
local function RemovePlaceholderTower()
if towerToSpawn then
towerToSpawn:Destroy()
towerToSpawn = nil
rotation = 0
mapBoundaries(1)
gui.Controls.Visible = false
end
end
local function AddPlaceholderTower(name)
local towerExists = towers:FindFirstChild(name)
if towerExists then
RemovePlaceholderTower()
towerToSpawn = towerExists:Clone()
towerToSpawn.Parent = workspace.Towers
local Outline = ReplicatedStorage.Particle.Highlights.Tower.TowerPlaceHolderHighlight:Clone()
Outline.Parent = towerToSpawn
CreateRangeCirclePlaceHolder(towerToSpawn, true)
for i, object in ipairs(towerToSpawn:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Tower"
end
end
mapBoundaries(0.5)
gui.Controls.Visible = true
end
end
local function SpawnNewTower()
if canPlace then
local placedTower = spawnTowerFunction:InvokeServer(towerToSpawn.Name, towerToSpawn.PrimaryPart.CFrame)
if placedTower then
placedTowers += 1
gui.Sounds.Place:Play()
RemovePlaceholderTower()
toggleTowerInfo()
mapBoundaries(1)
if placedTower.Config.Owner.Value == Players.LocalPlayer.Name then
local boxHeight = (placedTower.PrimaryPart.Size.Y) - placedTower.Humanoid.HipHeight
local boxOffset = CFrame.new(0, -boxHeight, 0)
local boxPrefab = ReplicatedStorage:WaitForChild("Box")
local box = boxPrefab:Clone()
box.Size = Vector3.new(placedTower.PrimaryPart.Size.Y * 1.75, placedTower.PrimaryPart.Size.Y * 1.75, placedTower.PrimaryPart.Size.Y * 1.75)
box.Parent = placedTower
box.CFrame = placedTower.PrimaryPart.CFrame * boxOffset
end
end
else
Error("You can't place that there!")
end
end
the rest of the script is where i set the transparency