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
You would use something called RemoteEvents
or RemoteFunctions
. You will need to understand the Data Model and Filtering Enabled in order to use these. See this web-page for more details