Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i randomly select something from a folder when a player touches a block?

right so i have 8 folders and a brick so when someone touches a brick I want it to randomly select something from the folder and put it into the workspace. At the moment I have this inserted in a brick and have no idea why it doesn't work.

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	--first room random
	local maproom1 = game.Lighting.Room1
	local chosenmap = maproom1[math.random(1, #mapsinserverstorage)]
	chosenmap:Clone().Parent = game.workspace.MapStorage
end

script.Parent.Touched:connect(onTouch)

4 comments

0

where are the folders located?

0

lighting

0

game:GetService("Lighting"):GetDescendants()

0

You should not be using lighting for storage. And use workspace or game.Workspace, as game.workspace is deprecated

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.