[SOLVED] Compromising Folder > Part to Apply to Mutiple Parts

I am trying to make this Script in the placement of ServerScriptService reference the Battery which is associated in the Workspace > Map > KillArea > BatterySpawn > Battery x2. How will I factor into making this set work properly.

ServerScriptService Script:

local folder = workspace.Map.Zones.BatteryZone
local tool = game.Workspace.Map.KillArea.BatterySpawn.Battery
local toolSpawns = folder:GetChildren()

function batteryRespawn()
	local clone = tool:Clone()
	clone.CFrame = toolSpawns[math.random(1,#toolSpawns)].CFrame + 
		Vector3.new(2,1,0) -- Picks one random Spawns CFrame with Y offset of 1 stud.
	tool.Anchored = false
	wait(4.5)
	tool.Anchored = true
	tool.Orientation = Vector3.new (0, 0, 90)
	clone.Parent = workspace
	tool.Parent = workspace
end

game:GetService("ServerStorage").BatteryPickUp.BatteryRespawn.Event:Connect(batteryRespawn)

local toolSpawns = folder:GetChildren()
local clone = tool:Clone()
clone.CFrame = toolSpawns[math.random(1,#toolSpawns)].CFrame + Vector3.new(2,1,0) -- Picks one random Spawns CFrame with Y offset of 1 stud.
tool.Anchored = false
wait(4.5)
tool.Anchored = true
tool.Orientation = Vector3.new (0, 0, 90)
clone.Parent = workspace
tool.Parent = workspace

Other Helpful Terms (Same Script):

local tool for i, v in pairs(workspace.Map.KillArea.BatterySpawn:GetDescendants()) do
	task.spawn(function()
		if v:IsA("Part") and v.Name == "Battery" then
		end
	end)
end

“participation” doesn’t make sense in that sentence. It is difficult to understand what you are trying to achieve to give any useful advice.

1 Like

alright then, how about “colliding” and remove “the”

1 Like

Are you using a translator or something? “How will I factor into colliding of making this work properly” doesn’t make sense either. When you figure out a better explanation, edit the post so that it is easier for other people to understand, without them having to scroll down.

1 Like

re-read for what I have wrote, I have changed.

1 Like

Sorry I am very busy muti-tasking I am trying to text you and test my current game.

1 Like

I don’t understand what you’ve changed, but I have noticed some other problems:

You make a clone, but then edit the original and not the clone? This is also present in this section:

They seem to do the same thing though, so you should just be able to replace the block of code at the bottom with a simple batteryRespawn(). Within batteryRespawn, change everything under local clone = tool:Clone() from tool. to clone., like so:

Before:

function batteryRespawn()
	local clone = tool:Clone()
	clone.CFrame = toolSpawns[math.random(1,#toolSpawns)].CFrame + 
		Vector3.new(2,1,0) -- Picks one random Spawns CFrame with Y offset of 1 stud.
	tool.Anchored = false
	wait(4.5)
	tool.Anchored = true
	tool.Orientation = Vector3.new (0, 0, 90)
	clone.Parent = workspace
	tool.Parent = workspace
end

After:

function batteryRespawn()
	local clone = tool:Clone()
	clone.CFrame = toolSpawns[math.random(1,#toolSpawns)].CFrame + 
		Vector3.new(2,1,0) -- Picks one random Spawns CFrame with Y offset of 1 stud.
	clone.Anchored = false
	wait(4.5)
	clone.Anchored = true
	clone.Orientation = Vector3.new (0, 0, 90)
	clone.Parent = workspace
end

And,

game:GetService("ServerStorage").BatteryPickUp.BatteryRespawn.Event:Connect(batteryRespawn)

local toolSpawns = folder:GetChildren()
local clone = tool:Clone()
clone.CFrame = toolSpawns[math.random(1,#toolSpawns)].CFrame + Vector3.new(2,1,0) -- Picks one random Spawns CFrame with Y offset of 1 stud.
tool.Anchored = false
wait(4.5)
tool.Anchored = true
tool.Orientation = Vector3.new (0, 0, 90)
clone.Parent = workspace
tool.Parent = workspace

to:

game:GetService("ServerStorage").BatteryPickUp.BatteryRespawn.Event:Connect(batteryRespawn)

batteryRespawn()
1 Like

Thank you I appreciated that I will add in soon however, I am trying to make the BatteryLocation Script detect multiple Parts into a certified category for instance: Workspace > Map > KillArea > BatterySpawn > Battery x2.

1 Like

any idea of how I can do this?

1 Like

ended up fixing this myself, so thank you for helping everyone!

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