Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

attempt to index nil with 'Transparency?

Asked by 2 years ago
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.

0
Is "WreckJailDoor" a part or a model? ShaShxa 105 — 2y
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. Spjureeedd 385 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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)
Ad

Answer this question