Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

attempt to index nil with 'Transparency?

local ProximityPrompt = script.Parent
local Torch = script.Parent.Parent
local Jailcell = game.Workspace:FindFirstChild("Jailcell1")
local Wrecked = game.Workspace:FindFirstChild("WreckedJailDoor")

ProximityPrompt.Triggered:Connect(function()
	if ProximityPrompt.ActionText == "Burn a hole trough the jail door?" then
		wait(2)
		Jailcell.Position = Vector3.new(-75.25, 5, -191.5)
		ProximityPrompt.ActionText = "Burned..."
	else
		wait(0.5)
		workspace.Basement.Doors.Jailcell1:Destroy()
		wait(0.1)
	game.Workspace:FindFirstChild("WreckedJailDoor").Transparency = 0
	game.Workspace:FindFirstChild("WreckedJailDoor").CanCollide = true
	game.Workspace:FindFirstChild("WreckedJailDoor").Anchored = true
		
		return
	end
end)

Im trying to make it so that the original jailcell gets destroyed, but then want the Wrecked version with the hole in it to be seeable and be collided with, and keep getting the error.

2 comments

0

Is "WreckJailDoor" a part or a model?

0

On line 17 you set it to Anchored = true. Is it not Anchored from the start? If you start the game and it is not Anchored and CanCollide is false, it will fall down in the "void" and be destroyed.

1 answer

Hiya! o/

The error that's being supplied is telling us that on line 15, it attempts to find "WreckedJailDoor" in Workspace, but it's returning nothing. Perhaps the object is getting destroyed somewhere during runtime? Could you confirm that the door is still in workspace after you tried to trigger the prompt?

Another cause could be because you might be spelling it wrong?

Also might I add you can use the variables you created earlier in your code

local ProximityPrompt = script.Parent
local Torch = script.Parent.Parent
local Jailcell = game.Workspace:FindFirstChild("Jailcell1")
local Wrecked = game.Workspace:FindFirstChild("WreckedJailDoor")

ProximityPrompt.Triggered:Connect(function()
    if ProximityPrompt.ActionText == "Burn a hole trough the jail door?" then
        wait(2)
        Jailcell.Position = Vector3.new(-75.25, 5, -191.5)
        ProximityPrompt.ActionText = "Burned..."
    else
        wait(0.5)
        Jailcell:Destroy()
        wait(0.1)
        Wrecked.Transparency = 0
        Wrecked.CanCollide = true
        Wrecked.Anchored = true
        return
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.