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

Like connecting a "Server Script" with another "Server Script" through a removeEvets?

Asked by 7 years ago

I am making a door that when you enter changes a value saved in the "PlayerGui", I did it with RemoteEvents. When I test it online it says "FireServer can only be called from the client"

Server Script

script.Parent.Touched:connect(function(hit)
if hit.Parent == nil then return end  
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
local basein=game.ReplicatedStorage:WaitForChild("basein") basein:FireServer() 
end 
end)

*Server Script (This script is in "ServerScriptService") *

basein=Instance.new("RemoteEvent", game.ReplicatedStorage)
basein.Name="basein"
basein.OnServerEvent:connect(function(player)
player:WaitForChild("PlayerGui"):FindFirstChild("ADframe").Value = "Base"
end)

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

So if you are NOT communicating from Server to Client (vice versa) and wish to communicate between ONLY the Client or ONLY the Server, you would use a BindableEvent or BindableFunction.

Here is a link to BindableEvents from the wiki: http://wiki.roblox.com/index.php?title=API:Class/BindableEvent

An Example:

Server Script 1:

local BindableEvent = game.ReplicatedStorage.PrintSomething

PrintSomething:Fire("This is being sent to the other script")

Server Script 2:

local BindableEvent = game.ReplicatedStorage.PrintSomething

PrintSomething.Event:connect(function(Message)
    print(Message)
end)

So in your case, you would change the following:

"basein:FireServer()" to "basein:Fire()"

"basein.OnServerEvent" to "basein.Event"

You will also need to change 'basein' to a BindableEvent/BindableFunction

Hope this helps!

Ad

Answer this question