Hello, I am a little stuck on this and not sure if this is a normal way to manage multiple prompts in your game or if this is a proper way
I’m wanting to check what proximity prompt the player is triggering and right now when they trigger a prompt, I check for the prompts name, and then run certain code depending on the name of the prompt
I made some examples to make it clear
I just need to know if this is a good way of what I’m trying to do cause its doesnt sound like proper way lol
function Module.PromptTriggered(Prompt)
Prompt.Triggered:Connect(function()
if CoolDown then return end
CoolDown = true
if Prompt.Name == "Test1" then
-- Example: when triggered the player strinks
elseif Prompt.Name == "Test2" then
-- Example: when triggered the player gets teleported
elseif Prompt.Name == "Test3" then
-- Example: when triggered the player gets 100 cash
end
task.wait(1)
CoolDown = false
end)
end
hmm, I am not sure what you mean by that and the code on that page is long, do you mean like referencing all prompts in a variable and connect them to seperate function?
I agree with what Lit is saying, is there a reason why you want to run all the proximity prompts events through a single function? otherwise I don’t see why you wouldn’t just make separate functions.
Its really a question of would you rather have one long script with multiple if else statements, or you could have one long script / multiple scripts with functions for each trigger event
Edit: Personally i would just make one script for each proximity prompt, and parent the script to the prompt itself, Its much more orderly in my head
I’m just gonna do what I’m doing already but I’m gonna script the proximity prompts in separate modules and parent the modules under the proximity prompt module but thanks for the help from both of you