How do i make a random table that selects something only once

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make the CFrame of a Tool randomly the same as a CFrame of a SpawnPart but
only once for every SpawnPart. because I want a random finite amount of tools for each round in the game

  1. What is the issue? Include screenshots / videos if possible!

I don’t know how to do this I made a value called CanSpawnPart but to me, it doesn’t work

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

typing this is searching for a solution I think

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

-- SERVER SCRIPT

local WorkspacePartFolder = game.Workspace:FindFirstChild("WorkspacePartFolder")

local SpawnPlaceFolder = game.Workspace:FindFirstChild("SpawnPlaceFolder")

local MovePartToDestination = game.ReplicatedStorage.ReplicatedPartFolder:GetChildren()

local ToolFromReplicatedStorage = game.ReplicatedStorage.ReplicatedToolFolder:FindFirstChild("BloxFlakesTool")

local Tools = game.Workspace.WorkspacePartFolder


Tools.ChildAdded:Connect(function(descendant)
	
	
	local randomSpawn = SpawnPlaceFolder:GetChildren()[math.random(1,#SpawnPlaceFolder:GetChildren())]
	
	
		descendant.CFrame = randomSpawn.CFrame
	
	
	
	
		descendant.BrickColor = BrickColor.new("Really red")
		
		descendant.ProximityPrompt.Triggered:Connect(function(player)
		descendant:Destroy()
		local EquippedTool = ToolFromReplicatedStorage:Clone()
		EquippedTool.Parent = player:FindFirstChild("Backpack")
		end)
		
end)

wait(1.5)

for i, objects in pairs(MovePartToDestination) do
	objects.Parent = WorkspacePartFolder
	
end
1 Like
local WorkspacePartFolder = game.Workspace:FindFirstChild("WorkspacePartFolder")
local SpawnPlaceFolder = game.Workspace:FindFirstChild("SpawnPlaceFolder")
local MovePartToDestination = game.ReplicatedStorage.ReplicatedPartFolder:GetChildren()
local ToolFromReplicatedStorage = game.ReplicatedStorage.ReplicatedToolFolder:FindFirstChild("BloxFlakesTool")
local Tools = game.Workspace.WorkspacePartFolder

Tools.ChildAdded:Connect(function(descendant)
	local randomSpawn = SpawnPlaceFolder:GetChildren()[math.random(1,#SpawnPlaceFolder:GetChildren())]
	descendant.CFrame = randomSpawn.CFrame
	descendant.BrickColor = BrickColor.new("Really red")
	descendant.ProximityPrompt.Triggered:Connect(function(player)
		descendant:Destroy()
		local EquippedTool = ToolFromReplicatedStorage:Clone()
		EquippedTool.Parent = player:FindFirstChild("Backpack")
	end)
end)

wait(1.5)
for _, object in pairs(MovePartToDestination) do
	object.Parent = WorkspacePartFolder
end

No modifications, I’ve just reformatted the code snippet for ease of viewing.

3 Likes