I have question about using parameters of function

  1. What do you want to achieve?

I have a question about using a function to connect to an event. I want to make a system that teleports players if the player interacts with ProximityPrompt (if anything, I want to simplify the script… So that later I don’t have to put it for each part.). I need the player parameter and all 2 nodes. If the player interacts with a node, then the player will be teleported to another node.

  1. What is the issue?
    There is a problem with the parameters for the teleportTo() function. How to correctly make sure that not one parameter is responsible for an action, but all of them? In developer hub there is only one parameter there. I can’t find it on YouTube.

  2. What solutions have you tried so far?
    I’m still looking for a way. I searched on the Internet, but to no avail.

local Castle_Combat = script.Parent.Castle_Combat 
local Castle_Training = script.Parent.Castle_Training 
local Castle_UG = script.Parent.Castle_UG
local Castle_Zeppelin = script.Parent.Castle_Zeppelin

function teleportTo(Node1 : Instance, Node2 : Instance, player) -- What I need to do?
	---I will fill soon.

---All "Triggered" events

what do you mean “no one parameter is responsible for an action but all of them”

1 Like

About using “playerWhoTriggered: Player”. I don’t know how to correctly set the parameters on line 8. playerWhoTriggered: Player is main parameter for triggered event.

Ouch, after “:Connect()”
Sorry, I’m confused with the :Connect method for the “Triggered” event.

1 Like

well since upi using multiple parameters, you should first put the player parameter first before node1 and node2 as it is what the triggered event passes and instead of connecting that to the proximity prompt create a new annyamous function there and pass in the arguments that way like

function teleportTo(player: Player,Node1 : Instance, Node2 : Instance,) -- What I need to do?
	---I will fill soon.
teleportTo(player,node1,node2) -- you choose how to set thos

you have to do it this way because if you just tell the proximity prompt to call teleport to whenever its triggered, it will only use the player argument.


Okay, I have to do it this way… I thought it could be done differently.
Well, thanks for the answer anyway. :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.