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

Why is my remote in replicated storage not doing anything?

Asked by 6 years ago

I am completely new to using remotes and I am trying them for the first time.

I am trying to make something with them but it is not working.

These are scripts I have in replicated storage.

script.MoreThan2PlayersRemote.OnServerEvent:connect(function()
    script.Parent.MoreThan2PlayersYN.Value = true
    print("more than 2 players remote worked!")
end)
script.LessThan2PlayersRemote.OnServerEvent:connect(function()
    script.Parent.MoreThan2PlayersYN.Value = false
    print("less than 2 players remote worked!")
end)

And this is a script I have in the starter pack.

function CheckPlayers()
    local players = game:GetService("Players"):GetPlayers()
    if #players <= 1 then
        game.ReplicatedStorage.LessThan2Players.LessThan2PlayersRemote:FireServer()
    else
        game.ReplicatedStorage.MoreThan2Players.MoreThan2PlayersRemote:FireServer()
    end
end

print("player check for remote loaded")

while wait(1) do
    CheckPlayers()
end

I have the remotes inside of each script and the value in replicated storage with it.

There is no error just nothing is happening and nothing is being printed. I probably have a obvious mistake but I can't seem to find it.

Any help would be greatly appreciated.

1 answer

Log in to vote
1
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

Scripts don't run in game.ReplicatedStorage. Instead, move the Script to game.ServerScriptService and change it so it references the RemoteEvents.

Ad

Answer this question