Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
quinzt 201 Moderation Voter
4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited by Ziffixture 4 years ago

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

0
You would use a RemoteFunction. Ziffixture 6913 — 4y
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 quinzt 201 — 4y
Ad

Answer this question