I am making a game like bear on Roblox (of course), I am trying to make the script were you get picked for either the bear or a survivor, and I am stuck. I am now trying to use remote events to help with that, but still stuck. Not sure how to fire and receive it. Here is the script ive got going right now (server script, inside of server script service)
wait(15)
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local PlayersTable = Players:GetPlayers()
local RandomPlayer = PlayersTable[math.random(#PlayersTable)]
wait()
for i = 1, #PlayersTable do
local Player = PlayersTable[i]
local camsir = Player:WaitForChild("PlayerGui"):WaitForChild("CameraGui"):WaitForChild("sirs")
local cam = RandomPlayer:WaitForChild("PlayerGui"):WaitForChild("CameraGui"):WaitForChild("joys")
if Player == RandomPlayer then
Player.Team = Teams["Joy"]
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvents")
local function joygui(player)
remoteEvent:FireClient(player)
end
else
Player.Team = Teams["Survivor"]
Player.PlayerGui.CameraGui.sirs.Disabled = false
local remoteEventnon = Player.PlayerGui.CameraGui:WaitForChild("RemoteEvent")
end
end
Line 16-18
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvents")
local function joygui(player)
remoteEvent:FireClient(player)
Is the one I am confused on, and here is the script where it receives it:
local remoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvents")
remoteevent.OnClientEvent:Connect()
print("hi")
script.Parent.joys.Disabled = false
(joys is the script that handles everything, e.g. gui, animation, teleports)
I’ve looked at the Remote Functions and Events in the dev-hub. But I am still as confused as a 1 year old learning calculus. I looked at some tutorials, but they only seem to focus on client>server communications, instead of server>client. The remote event is inside of ReplicatedStorage, so no need to worry about that.
Thanks for your help, if any more info is needed, I will provide it