Hello, I have a function, and I want to find the destination of the model that passes through it. I have done it so it finds the part Destination, I just dont know what would go at the --something here comment. I am trying to get the value of Destination and then calling the appropriate. function.
local function onTouch(part) if part.Parent:findFirstChild("Destination") then --Something here if Destination.Value == "York" then InL() end end end script.parent.Collider.Touched:connect(onTouch)
If anyone could help that would be great!
Thanks.
Please check the wiki on how to create and use Variables and also please use FindFirstChild.
You can create a local variable in the function to hold the return value of the function call FindFirstChild like this.
-- example of creating a function and assigning the value to the variable local onTouch2 = function() end -- this is similar to the code above see https://i.imgur.com/rkGibSm.png local function onTouch(part) local Destination = part.Parent:FindFirstChild("Destination") if Destination then if Destination.Value == "York" then InL() end end end script.parent.Collider.Touched:Connect(onTouch) -- pls use :Connect
Hope this helps.