I’m currently facing an issue with my ProximityPrompt not triggering I have a lever system where a lever is spawned at a random location within a room. When a player interacts with the lever, it should move and rotate. However, despite the ProximityPrompt appearing, it doesn’t trigger the interaction.
Here is the script I’m using for the lever interaction:
local lever = {}
function lever.Interact(prompt, leverClone)
print("Lever is pulled")
prompt.Enabled = false
end
function lever.Spawn(room)
local LeverClone = workspace.itemsNotTools.VentLever:Clone()
local leverFolder = room.Build:WaitForChild("LeverSpawns")
local spawnPoints = leverFolder:GetChildren()
if #spawnPoints > 0 then
local randomSpawn = spawnPoints[math.random(1, #spawnPoints)]
LeverClone:PivotTo(randomSpawn.CFrame)
LeverClone.Parent = room
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "Pull Lever"
prompt.MaxActivationDistance = 5
prompt.Style = Enum.ProximityPromptStyle.Custom
prompt.RequiresLineOfSight = false
prompt.Parent = randomSpawn
prompt.Triggered:Connect(function(player)
print("Lever flicked by ", player.Name)
lever.Interact(prompt, LeverClone)
end)
end
end
return lever
Despite the ProximityPrompt being visible and seemingly functional, the prompt.Triggered event does not fire when I interact with it.
I have called the lever.spawn() in a different module, the lever does spawn but the triggered part doesn’t work. And the print line in the triggered function doesn’t get printed so for some reason it doesn’t detect that a player has triggered it.
this is your code, but without the randomising. Try and see maybe what’s wrong.
local lever = {}
local prompt
function lever.Interact(prompt, leverClone)
print("Lever is pulled")
prompt.Enabled = false
end
function lever.Spawn()
prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "Pull Lever"
prompt.MaxActivationDistance = 5
prompt.Style = Enum.ProximityPromptStyle.Default
prompt.RequiresLineOfSight = false
prompt.Parent = script.Parent
prompt.Triggered:Connect(function(player)
print("Lever flicked by ", player.Name)
lever.Interact(prompt, script.Parent)
end)
end
lever.Spawn()
return lever
It works, but I believe I found the issue, the actual prompt for some reason was cloning onto the original lever instead of the clone and it worked when I triggered the prompt on the original.