Help creating a system

so i want to create a system where when players walk through a security scanner, it’ll randomly select a player to be stopped and required to do a little interactive minigame, the security scanner has a part called WalkThrough and when a player walks through it, it should randomly stop them using a probability maybe and an NPC will use bubble chat to say Stop! Move over, and they’ll point to an area and then another rig will search them using the security wand thing and the player will need to play a minigame like pressing specific buttons to move limbs and if they don’t do it in time the Rig will bubblechat and like yell at them to do it or hurry up. I apologize for making this so long and I would like help creating the foundation for a system like this.

1 Like

I’m not going to write your entire script for you, however, you could use a touched function and run it through math.random(). For instance

script.Parent.WalkThrough.OnTouched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then

          local result = math.random(1,6) -- Change this to whatever you want the probability to be
          if result == 1 then

-- Script that sends them to be searched

          end
     end
end)