I am currently making a game and my script wont work any help at all please??? here is my script
1 | TP = script.Parent -- this script is a server script if that helps |
2 | gamie = game.ReplicatedStorage.Game |
3 |
4 | TP.Touched:Connect( function (touch) |
5 | local RP = game:GetService( "ReplicatedStorage" ) |
6 | local Co = RP.Co |
7 | Co:FireServer(touch) |
8 | end ) |
and here is my other script that is supposed to receive the remote event
01 | local gamie = game.ReplicatedStorage.Game --this script is also a server script |
02 | local intro = game.ReplicatedStorage.Intro |
03 | local timer = game.ReplicatedStorage.Timer |
04 | lava = game.ReplicatedStorage.Lava |
05 | local rs = game:GetService( 'ReplicatedStorage' ).Restart |
06 |
07 | rs.OnServerEvent:Connect( function (touch) |
08 | timer.Value = 20 |
09 | intro.Value = 1 |
10 | local clone = game.ReplicatedStorage.Lava 2 :Clone() |
11 | clone.Parent = game.Workspace |
12 | if lava.Parent = = game.ReplicatedStorage then |
13 | lava.Parent = game.Workspace |
14 | end |
15 | wait( 1 ) |
this script (shown above) may look kinda wonkie because of the autosave :-<
When you are trying to communicate with 2 server-sided scripts you have to use an instance called "Bindable Event".
First server-sided script
1 | TP = script.Parent -- this script is a server script if that helps |
2 | gamie = game.ReplicatedStorage.Game -- Make Game bindable event |
3 |
4 | TP.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. |
8 | end ) |
Second server-sided script
01 | local gamie = game.ReplicatedStorage.Game --this script is also a server script |
02 | local intro = game.ReplicatedStorage.Intro |
03 | local timer = game.ReplicatedStorage.Timer |
04 | lava = game.ReplicatedStorage.Lava |
05 | local rs = game:GetService( 'ReplicatedStorage' ).Restart |
06 |
07 | rs.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.Lava 2 :Clone() |
11 | clone.Parent = game.Workspace |
12 | if lava.Parent = = game.ReplicatedStorage then |
13 | lava.Parent = game.Workspace |
14 | end |
15 | wait( 1 ) |