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 3 years ago

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

TP = script.Parent -- this script is a server script if that helps
gamie = game.ReplicatedStorage.Game

TP.Touched:Connect(function(touch)
    local RP = game:GetService("ReplicatedStorage")
    local Co = RP.Co
    Co:FireServer(touch)
end)

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

local gamie = game.ReplicatedStorage.Game --this script is also a server script
local intro = game.ReplicatedStorage.Intro
local timer = game.ReplicatedStorage.Timer
lava = game.ReplicatedStorage.Lava
local rs = game:GetService('ReplicatedStorage').Restart 

rs.OnServerEvent:Connect(function(touch)
        timer.Value = 20
    intro.Value = 1
    local clone = game.ReplicatedStorage.Lava2:Clone()
    clone.Parent = game.Workspace       
        if lava.Parent == game.ReplicatedStorage then 
            lava.Parent = game.Workspace
        end
        wait(1)
        if lava.Parent == game.Workspace then
            lava.Parent = game.ReplicatedStorage
        end
        clone:Destroy()
        wait(3)
end)

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

1 answer

Log in to vote
0
Answered by 3 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

TP = script.Parent -- this script is a server script if that helps
gamie = game.ReplicatedStorage.Game -- Make Game bindable event

TP.Touched:Connect(function(touch)
    local RP = game:GetService("ReplicatedStorage")
    local Co = RP.Co
    Co:Fire(touch) -- Bindable events use "Fire" to trigger.
end)

Second server-sided script

local gamie = game.ReplicatedStorage.Game --this script is also a server script
local intro = game.ReplicatedStorage.Intro
local timer = game.ReplicatedStorage.Timer
lava = game.ReplicatedStorage.Lava
local rs = game:GetService('ReplicatedStorage').Restart 

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
        timer.Value = 20
    intro.Value = 1
    local clone = game.ReplicatedStorage.Lava2:Clone()
    clone.Parent = game.Workspace       
        if lava.Parent == game.ReplicatedStorage then 
            lava.Parent = game.Workspace
        end
        wait(1)
        if lava.Parent == game.Workspace then
            lava.Parent = game.ReplicatedStorage
        end
        clone:Destroy()
        wait(3)
end)

0
gamie was something i left in there Lamborghinihurican0 4 — 3y
Ad

Answer this question