Updated specific locations to be searchable, take a look at Las Vegas as an example.

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Problem with waitforchild I know ima noobie and ive been stuck on this for like 20 minutes I JUST CANT GET IT TO WORK THIS STUPID ERROR MESSAGE "Workspace.Locked Door.Door.Script:11: attempt to index nil with 'WaitForChild'"
Post Flair (click to view more posts with a particular flair)
Post Body

-- Define variables

local key = script.Parent.Parent.Key.Value

local keyRemove = script.Parent.Parent.KeyRemove.Value

local proximityPrompt = script.Parent:FindFirstChildOfClass("ProximityPrompt")

wait(0.9)

wait(0.9)

wait(0.9)

-- Define function to check if player has the key

local function playerHasKey(player)

local playerInventory = player:WaitForChild("Inventory"):GetChildren()

for i, item in ipairs(playerInventory) do

    if item.Name == key then

        return true

    end

end

return false

end

-- Define function to handle proximity prompt

local function onPromptTriggered(prompt, player)

if playerHasKey(player) then

    if keyRemove then

        local keyInCharacter = player:FindFirstChild(key)

        if keyInCharacter then

keyInCharacter:Destroy()

        end

    end

    script.Parent.Transparency = 0.8

    script.Parent.CanCollide = false

    wait(3)

    script.Parent.Transparency = 0

    script.Parent.CanCollide = true

end

end

-- Connect proximity prompt to function

if proximityPrompt then

proximityPrompt.Triggered:Connect(onPromptTriggered)

end

-- Define function to handle touch event

local function onTouched(hit)

local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")

if humanoid then

    local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)

    if player then

        if playerHasKey(player) and hit.Parent:FindFirstChild(key) then

onPromptTriggered(nil, player)

        end

    end

end

end

-- Connect touch event to function

script.Parent.Touched:Connect(onTouched)

Comments

local playerInventory = player:WaitForChild("Inventory"):GetChildren()

In the line above replace Inventory with Backpack, there is no class called Inventory inside of the local player unless you instanced one in another script, should look like

local playerInventory = player:WaitForChild("Backpack"):GetChildren()

Author
Account Strength
90%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
817
Link Karma
629
Comment Karma
151
Profile updated: 4 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago