You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
This is kind of simillar to what i asked yesterday but this time im talking about the script directly rather
than the plugin itself, So the gist is that ive got a MS here with a return function that im trying to return as true if the player triggers a proximity prompt.
-
What is the issue? Include screenshots / videos if possible!
The script is still returning as false even though the player has interacted with the proximity prompt and the output isnt printing any errors so i dont got a clue why its doing this.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Ive already took a gander at the Dev Forum for this issue and ive really not seen anything simillar to my question so I dont got anything to build off of.
Heres the script itself
return function(player)
local proximityPrompt = game.Workspace.Teleporter.Interact.ProximityPrompt
proximityPrompt.Triggered:Connect(function(Caller)
return true -- Returns True because codition is met so insert message `
end)
return false --Returns False because condition isnt met so insert message 2
end;
And heres a quick little video (Note how the message didnt change even after the player pressed the proximity prompt)
robloxapp-20230924-1205199.wmv (1.1 MB)
1 Like
maybe because you’re returning a return. (return function() … return true… )
Oh pardon me i didnt mention why i did that, Its mainly becasue the script has to return true for a condition to pass. if it doesnt return true (and i.e returns false) it will use a lower priority message.
I’m not sure I can put this into words well, but I’ll try:
- The function you’re connecting to the
proximityPrompt.Triggered event will only run when the proximity prompt is triggered. Essentially, the modulescript will just skip over that and continue straight to the return false line. Only when the prompt is triggered will it run the said function.
-
return statements will exit the current function, not the first called function, Since you have a function inside of a function, the return in the interior function will exit the interior function, and the return in the exterior function will exit the exterior function.
...
proximityPrompt.Triggered:Connect(function(Caller)
return true -- This will return true as the result of the connection that you just defined
end)
return false -- This will return false whenever the modulescript is called
end;
Try changing the return statements to print statements, and observe what happens when you call the function and trigger the proximity prompt.
Here is an example of how you could fix this, although it is not the most efficient:
local hasPlayerTriggeredPrompt = false
local proximityPrompt = workspace.Teleporter.Interact.ProximityPrompt
proximityPrompt.Triggered:Once(function() -- Once is similar to Connect, but automatically disconnects the function after being triggered once.
hasPlayerTriggeredPrompt = true
end)
return hasPlayerTriggeredPrompt
1 Like
You are correct, it seems as so that my script didnt end up working becasue of that exterior and interior function factor. But for some odd reason even after adding the changes you provided, dialogue 2 still seems to be the only one that shows up even after the player has triggered the proximty prompt. Output is being as silent as ever but i presume id need to print something for it to make noise.