Roblox Heist: Key and Door

Planning
Step 1
In this lesson you will be challenged to use what you have learned so far to create a locked door

You'll need to make a Key in the form of a Tool

Temp1532058978 Temp1532646852

I kept it simple with a red box shaped Handle which I call a KeyCard

Step 2
Create some kind of door, you can give it a SurfaceGUI if you'd like to give it a sign like I did
Temp1532059142
Challenge
Step 3
Create a key and use this starter code snippet to add a Script to the Door which opens only if the player has the key

This checks if the player who collided with the door is holding a "KeyCard" in their hand.

local door = script.Parent

function onTouched(collider)
    local player = collider.parent

    if player:FindFirstChild("KeyCard") then
              --Set the door's CanCollide to false
              --Set the door's Transparency to 0.5
              wait(2)
              --Return the door back to normal
    end
end

Replace the comments with working code

Hint: remember to Connect this function after completing it

Check Your Work
Step 4
This is how it should look when completed
Planning
Step 5
In the next lesson we will make a "PoliceChase" Script play when the player steals the jewel

In my game the player has to jump through the keycard door and escape to the helicopter before time runs out

Press the play button to watch a close call demonstration

Roblox Heist: Key and Door Info

Account

MVCode Clubs

Created By

Newprofile jamie

Course:

Roblox Heist Game

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach