I made a simple script that displays something ( ui ) when I interact with a proximity prompt. It works, no problems in the output.
But when I import this script into another roblox studio project, I get an error in the output which is not logical because it should work.
here is the structure of my system, the proximity prompt in workspace :
I tested this script and it worked, but when I imported it into another project it no longer worked and displayed this in the output, even though I had put in the right calls to find the proximity prompt. I don’t understand, I’m beginning to despair
Maybe possibly try a waitforchild on ProximityPromtPart, for example:
local ProximityPart = game.Workspace.ShopModel:WaitForChild("ProximityPromptPart")
and use that variable to create the triggered function,
or maybe check if somehow proximitypromptpart is being deleted when you run the game? possibly you accidently set CanCollide to false and the part is falling through the world and being deleted?
Check if there are more objects in workspace that have the same name, use waitforchilds to safely get the proximity and make sure the script places are set correctly
As the two others said, use WaitForChild. If the script loads before the workspace (It’s in a Gui so I believe it does), then it may start running before what you’re trying to find exists.
(Though, if that’s the solution then it’s weird it works in one but not the other, maybe the order you add things to the workspace dictates the order they load in shrug)
I’m taking the liberty of sending you one last message about a similar problem. I used the “waitforchild” as you told me but it gives me an infinite yield and then when I click on the “buy” button, nothing happens.
why are you using a server script for that, use a local script with a remote event for what your trying to achieve (also at this point just make another topic so this already solved topic can close)
A solution to your problem would to be using parenting.
Because the script is inside startergui, everything inside startergui goes inside the playergui (The playergui is inside the player) when a player joins, to get the individual player, you would just have to do this:
local Player = script.parent.parent.parent.parent.parent.parent.parent
that should be a solution to your code unless i missed or added a extra .parent