I need a way to write a function in a local script then run it in a server script. I have to do that because I'm making a door that you open by clicking on a GUI that appears when you walk near the door. I have written that code by getting all the descendants of a folder and checking if its name is "button" Heres an example of what I want to get done: (simplified a little) local script:
local folder = workspace.folder
for _,v in pairs(folder:GetDescendants) do
if v.Name == "Button" then
GUI.Visible = true
door1 = v.Parent.door1
door2 = v.Parent.door2
end -- this is very simplified but its basically what im doing
function opendoor()
--[[is code to open door. it uses variables from the loop above which is the main reason why I
need to know how to do this]]--
end
server script inside door:
opendoor()--somehow?
anyway, that's what I need to do. if anyone could tell me how to do this that would be nice. thanks

2 comments
You would use a RemoteFunction.
how exactly would i go about doing this? i read the wiki article and according to it, i need to write the function in the server script which is what i dont want