#Lockpicking Doors using Proximity Prompts

18 messages · Page 1 of 1 (latest)

bright kraken
#

I don't know if this can help you, but this is an example I did:
local door = script.Parent
local player = game.Players.LocalPlayer

local locked = true
local lockpick = player.Backpack:FindFirstChild("Lockpick")

door.ProximityPrompt:Connect(function(player)
if locked then
door.ProximityPrompt:SendPrompt("Press E to try to pick the lock")
end
end)

door.Activated:Connect(function(player)
if not locked then
door:Open()
elseif lockpick then
local success = math.random() < 0.5
if success then
locked = false
door:Open()
else
door.ProximityPrompt:SendPrompt("The lockpick breaks!")
end
end
end)

dim pike
#

Will give it a try

native pantherBOT
#

studio** You are now Level 1! **studio

dim pike
#

I got attempt to call a nil value - server

#

When i tried adding that to get a baseline of how it would work

bright kraken
#

As an error?

dim pike
#

Yea

#

17:54:26.913 Workspace.Lockpickable Door.Doorframe.Lock.Door:32: attempt to index nil with 'Backpack' - Server - Door:32
17:54:26.913 Stack Begin - Studio
17:54:26.913 Script 'Workspace.Lockpickable Door.Doorframe.Lock.Door', Line 32 - Studio - Door:32
17:54:26.913 Stack End - Studio
17:54:39.945 attempt to call a nil value - Server

bright kraken
#

Show me how you wrote the script.

#

Or you just pasted and replaced the values?

dim pike
#

I just pasted at replaced the values to see if that would get it to work

bright kraken
#

Show me the script please.

dim pike
#
local door = script.Parent
local player = game.Players.LocalPlayer

local locked = true
local lockpick = player.Backpack("Lockpick")

door.ProximityPrompt:Connect(function(player)
    if locked then
        door.ProximityPrompt:SendPrompt("Press E to try to pick the lock")
    end
end)

door.Activated:Connect(function(player)
    if not locked then
        door:Open()
    elseif lockpick then
        local success = math.random() < 0.5
        if success then
            locked = false
            door:Open()
        else
            door.ProximityPrompt:SendPrompt("The lockpick breaks!")
        end
    end
end)

#

The value names are the same as your because all my stuff is named that way

#

but here ya go

bright kraken
#

Okay. First, in local lockpick set the FindFirstChild:

local lockpick = player.Backpack:FindFirstChild("Lockpick")
dim pike
#

Alright

#

Oh there go thanks!