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

Fireserver can only be called from the client???HELP

Asked by 4 years ago

I am currently making a game and my script wont work any help at all please??? here is my script

1TP = script.Parent -- this script is a server script if that helps
2gamie = game.ReplicatedStorage.Game
3 
4TP.Touched:Connect(function(touch)
5    local RP = game:GetService("ReplicatedStorage")
6    local Co = RP.Co
7    Co:FireServer(touch)
8end)

and here is my other script that is supposed to receive the remote event

01local gamie = game.ReplicatedStorage.Game --this script is also a server script
02local intro = game.ReplicatedStorage.Intro
03local timer = game.ReplicatedStorage.Timer
04lava = game.ReplicatedStorage.Lava
05local rs = game:GetService('ReplicatedStorage').Restart
06 
07rs.OnServerEvent:Connect(function(touch)
08        timer.Value = 20
09    intro.Value = 1
10    local clone = game.ReplicatedStorage.Lava2:Clone()
11    clone.Parent = game.Workspace      
12        if lava.Parent == game.ReplicatedStorage then
13            lava.Parent = game.Workspace
14        end
15        wait(1)
View all 21 lines...

this script (shown above) may look kinda wonkie because of the autosave :-<

1 answer

Log in to vote
0
Answered by 4 years ago

When you are trying to communicate with 2 server-sided scripts you have to use an instance called "Bindable Event".

First server-sided script

1TP = script.Parent -- this script is a server script if that helps
2gamie = game.ReplicatedStorage.Game -- Make Game bindable event
3 
4TP.Touched:Connect(function(touch)
5    local RP = game:GetService("ReplicatedStorage")
6    local Co = RP.Co
7    Co:Fire(touch) -- Bindable events use "Fire" to trigger.
8end)

Second server-sided script

01local gamie = game.ReplicatedStorage.Game --this script is also a server script
02local intro = game.ReplicatedStorage.Intro
03local timer = game.ReplicatedStorage.Timer
04lava = game.ReplicatedStorage.Lava
05local rs = game:GetService('ReplicatedStorage').Restart
06 
07rs.Event:Connect(function(touch) -- Also, to recognize a trigger from another script, the bindable event uses the .Event just like RemoteEvent uses .OnServerEvent or .OnClientEvent
08        timer.Value = 20
09    intro.Value = 1
10    local clone = game.ReplicatedStorage.Lava2:Clone()
11    clone.Parent = game.Workspace      
12        if lava.Parent == game.ReplicatedStorage then
13            lava.Parent = game.Workspace
14        end
15        wait(1)
View all 21 lines...
0
gamie was something i left in there Lamborghinihurican0 4 — 4y
Ad

Answer this question