Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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?

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 DuckyRobIox 280 — 3y
0
actually ima do it in the answer so it isnt confusing DuckyRobIox 280 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

0
oh ok I get it know angelocharles2007 16 — 3y
0
but how can i make it has no collision and invisible at the same time angelocharles2007 16 — 3y
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. angelocharles2007 16 — 3y
0
Oops I did do this on phone so sorry for the mistake also you can do part.Transparency = 1 DuckyRobIox 280 — 3y
Ad

Answer this question