ProximityPrompt problem

In simple terms, I’m making a cutscene, it starts by the user holding down “E” via ProximityPrompt. Because I don’t want the proximity prompt in the way of the cutscene, I coded it so that it would destroy it. After the cutscene I want it to be added back again so the player can play the cutscene twice, so I made a function that makes the ProximityPrompt and puts it inside the player. I putted the function at the start of the code then at the end of the code, when the cutscene ends.

The problem is that the cutscene would not play the second time even though the proximityprompt is present. What can I do to fix this? Thank you.

Heres the code

local function triggeredAdded()
	local triggered = Instance.new("ProximityPrompt")
	triggered.Name = "triggered"
	triggered.Parent = workspace.BlackMarket
	triggered.ActionText = "Black Market"
	triggered.Enabled = true
	triggered.HoldDuration = 1
	triggered.KeyboardKeyCode = "E"
end
triggeredAdded()

workspace.BlackMarket.triggered.Triggered:Connect(function()
	workspace.BlackMarket.triggered:Destroy()
	
	-- some code I put blah blah blah

	triggeredAdded()
    
end)

I would just do ProximityPrompt.Enabled = false, but if you don’t like that option, you can always try parenting the prompt to nil and back to the instance.

That way, the connection of the Triggered event doesn’t get disconnected; which is why your cutscene isn’t playing for the second time.

1 Like

Here’s some examples, just in case you were confused:

local Prompt = workspace.BlackMarket.triggered

Prompt.Triggered:Connect(function(Player)
    Prompt.Enabled = false
    - Cutscene
    Prompt.Enabled = true
end)
local Prompt = workspace.BlackMarket.triggered

Prompt.Triggered:Connect(function(Player)
    Prompt.Parent = nil
    - Cutscene
    Prompt.Parent = workspace.BlackMarket
end)

Thanks! I spent so long trying to figure out what to do just for it to be that simple

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.