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

Does anyone have a script to make 1 random part out of 4 will have no collision?

I'm trying to make a mini game for my game.You know the mini game 4 corners when one random colored part will disappear and kill the players on them by making them fall,yeah that's what I'm tying to do,I searched in YouTube but the script I found there is not working anymore.Can you help me please?

2 comments

0

you can use math.random(1,4) 1-3 = no collision and 4 can collide and then if the others get the same number make it redo until it isnt the same

0

actually ima do it in the answer so it isnt confusing

1 answer

✓ Accepted answer

Alright so basically start of by localizing the 4 parts into a function

local parts = {
  game.Workspace:WaitForChild("Part1")
  game.Workspace:WaitForChild("Part2")
  game.Workspace:WaitForChild("Part3")
  game.Workspace:WaitForChild("Part4")
}

for i, v in pairs(parts) do
  v.CanCollide = false
end
parts[math.random(1, #parts)].CanCollide = true

then use for blabla, blabla in pairs to have the parts randomize

accept it gives you a better understanding

4 comments

0

oh ok I get it know

0

but how can i make it has no collision and invisible at the same time

0

Theres a red line below the text indicating somethings wrong,but I got what it is because I had the same problem,you forgot the (,) in the end of the parts to indicate that there are many parts.

0

Oops I did do this on phone so sorry for the mistake also you can do part.Transparency = 1

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