Hello! Recently, I have been working on my own game. However, I have noticed a recurring issue that happens whenever I try to interact with a ProximityPrompt.
The prompt simply does not work. Screenshot of the code used to create the prompt itself is below.
I have tried using other events (such as TriggerEnded) but it still hasn’t worked. Sometimes, the ProximityPrompt.Triggered event actually works, however this is only on rare occasions.
The Prompt’s RequiresLineOfSight is turned off, the prompt is not cloned (it is created using Instance.new), the prompt is enabled. I have no idea why it isn’t working, but if someone knows or has had a similar problem to me and has fixed it, please tell me the solution.
The FireClient doesn’t work because of the Prompt.Triggered issue, normally it is supposed to send a message that only the player who picked up the item can see that shows how much items you got and what item you picked up.
Something I’m beginning to be unsure of is if it’s a specific problem with the item that is being dropped, as I can pick up another item but not specifically this one.
(as you can see in the chat, I could pick up the wood item but picking up the other item was refusing to work for me)
I will be investigating this further and hopefully fix this issue.
As seen in this video (if it loads), it shows me mining an ore, being unable to pick up the ore, then mining another ore and being able to pick up the drop.
I think the error is that the event is being connected very fast. I would recommend putting a wait before, but since it’s a Server Sided script, I recommend you to put it between a spawn task.
task.spawn(function()
task.wait(3)
-- rest of the triggered function (put all of the connection)
end)
Otherwise, it’s the statement that’s giving “silent errors”. If it doesn’t work, i recommend you after to put it between pcall functions
(you can also change the task.wait timer, 1 second at min)
task.spawn(function()
task.wait(2)
prompt.Triggered:Connect(function(player)
task.spawn(function()
task.wait(1)
-- rest
if item.stackable == true then
local inventory = player:FindFirstChild("Inventory")
if inventory == nil then
print("Didn't find inventory. Trying to access it")
repeat task.wait(.01)
inventory = player:FindFirstChild("Inventory")
print("Finding inventory..")
until inventory ~= nil
end
local item = inventory:FindFirstChild(itemName)
if item == nil then
print("Didn't find item")
repeat task.wait(.01)
item = inventory:FindFirstChild(itemName)
print("Finding item..")
until item~= nil
end
else
local inventory = player:FindFirstChild("Inventory")
if inventory == nil then
print("Didn't find inventory. Trying to access it")
repeat task.wait(.01)
inventory = player:FindFirstChild("Inventory")
print("Finding inventory..")
until inventory ~= nil
end
task.spawn(function()
for i = 1, amount do
local itemClone = item.object:Clone()
itemClone.Values.Amount.Value = 1
itemClone.Parent = inventory
end
end)
end
end)
end)
end)
This is an example of what @Scottifly gave (i think, sorry if i’m wrong for the credits)
Unfortunately, the problem seems to have resurfaced and the ‘solution’ was only temporary. The issue is still occurring and I have absolutely zero idea why. If I create a new part that has a ProximityPrompt and prints the player’s name with it, it works completely fine. Because of this, I think it has something to do with the code / the part itself, but I don’t know what…
The script is a ModuleScript. The prompt itself is created within a function inside the module script that is then used when an ore is broken. The function is called on the server-side.
Something I have noticed is that when the prompt becomes a bit too old (around 3 seconds from what I can see) it stops working but if it is triggered before then it works. No idea if this is just a coincidence or actually related to the issue.