I’m trying to get this loop to find all ProximityPrompt, however it only finds a few, what’s wrong?
CODE:
OUTPUT:
EXPLORER:
I’m trying to get this loop to find all ProximityPrompt, however it only finds a few, what’s wrong?
CODE:
OUTPUT:
EXPLORER:
this is due to your client script running before all proximity prompts have loaded
there are tons of ways to waiting for the game to load, one of them which may be good enough for what your trying to achieve is
game.Loaded:Once(function()
--your code here
end)
Try something like this:
for _, item in pairs(game.Workspace:GetDescendants()) do
if item:IsA("ProximityPrompt") then
print(item)
end
end
Isn’t finding the one inside the part
I’m running this script on a map that doesn’t have anything, but it still doesn’t work
The script is being ran locally
I’m using a LocalScript in StarterPlayerScripts
i think u could do this but im not sure what the next is for
for i, v in pairs (game.Workspace:GetDescendants()) do
if v.Class == "ProximityPrompt" then
print(v) or print(v.Name)
end
end
I have already tested and it came up from this output.
22:33:11.507 ProximityPrompt - Server - Script:3
22:33:11.508 ProximityPrompt - Server - Script:3
22:33:11.509 ProximityPrompt - Server - Script:3
I’m running a LocalScript,won’t work!
Copy and paste into the local script then test it.
Yea, I saw the comments above afterwards.
LocalScript, right.
Maybe add some waits for the player and the character, like:
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
That way, you know the “game” is loaded.
the code only works in Script, but when I put it in LocalScript it doesn’t pick up all prompts
When I test it in the localscript, it works.
Are you sure you’re testing by pressing f5?
Because local is client.
Because this is what it came up in the f5 test.
This code works in a LocalScript:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local WS = game:GetService("Workspace")
for _, item in pairs(WS:GetDescendants()) do
if item:IsA("ProximityPrompt") then
print(item)
end
end
LocalScripts load faster than the instances themselves. Maybe try doing something with CollectionService?
Currently testing around with pretty much everything, not even CollectionService will give me the 3 prompts
For whatever reason roblox is basically saying the game is loaded when it hasnt