Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to run a function in a server script that's written in a local script?

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

1 answer

✓ Accepted answer

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

2 comments

0

You would use a RemoteFunction.

0

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

This discussion is preserved as it was. New answers, comments, and votes are closed.