Edit: Thank you to those who helped me with this, I appreciate it
Make A Folder. Store all of the Parts inside the Folder And then
Check on this Script.
local AllPartsFolder = -- Define the Folder u Created
local Part = script.Parent -- Define the Touch Part
local TouchDebounce = false
Part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and TouchDebounce == false then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then -- Valid Player Touched It
TouchDebounce = true
local FolderChildren = AllPartsFolder:GetChildren()
local Index = math.random(#FolderChildren)
local Instance = FolderChildren[Index]
Hit.Parent:MoveTo(AllPartsFolder:FindFirstChild(Instance.Name).Position)
wait(1)
TouchDebounce = false
end
end
end)
Make sure All Parts are Named Different and Are Stored inside the Folder.
let me see your explorer inside workspace if you still having issue
did you define the folder on line 1 as Forceman mentioned?
You probably did not define the variable on line 1 .
You need to put the script inside all 5 parts. Not in the folder.
the script must inside the Part not Folder and I rewrote this script:
local AllPartsFolder = script.Parent.Parent -- Define the Folder u Created
local Part = script.Parent -- Define the Touch Part
local TouchDebounce = false
Part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") and TouchDebounce == false then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Player then -- Valid Player Touched It
TouchDebounce = true
local FolderChildren = AllPartsFolder:GetChildren()
local Index = math.random(#FolderChildren)
local Instance = FolderChildren[Index]
Hit.Parent:MoveTo(AllPartsFolder:FindFirstChild(Instance.Name).Position)
wait(1)
TouchDebounce = false
end
end
end)
Make sure all your Part’s name differently
For OP, please do not just copy and paste script, instead try examing the error.
I had been trying to solve it, but my understanding of lua is very limited and scripting isn’t necessarily my strong suit either
Well i’m happy your error was solved.
Just as @ItzMeZeus_IGotHacked said,
I Gave The script as an example of what you had to do.