Hey, I’m trying to make a gui’s visible to true whenever the event is called, however I had some trouble passing on the player paramater from server so the remote events in the module script and the local script can access it, however I am getting this error.
I am calling my module in server, therefore i need player in server, then I’m using the module to fire a remote event to the client, then i need that player paramater in the local.
Here is my code.
--- SERVER ---
local gameStatusModule = require(game.ReplicatedStorage.GameStatusModule)
local roleModule = require(game.ReplicatedStorage.RoleModule)
local Players = game:GetService("Players")
local player = Players.PlayerAdded:Wait()
local inRound = false
local enoughPlayers = false
local isEnoughPlayers = gameStatusModule.notEnoughPlayers
while task.wait() do
if #Players:GetPlayers() < 2 then
warn("not enough players")
gameStatusModule.notEnoughPlayers("Need at least 1 more player to start!")
elseif #Players:GetPlayers() >= 2 and inRound == false then
warn("run intermission")
gameStatusModule.intermission("Intermission: ")
roleModule.roleSelector(player) -- how do I get player here?
local isIntermissionFinished = gameStatusModule.intermission
if isIntermissionFinished then
inRound = true
warn("run game")
gameStatusModule.startGame("Drawer has ")
local isGameFinished = gameStatusModule.startGame
if isGameFinished then
inRound = false
warn("game ended")
end
end
end
end
--- MODULE ---
local roleModule = {}
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local roleEvent = game.ReplicatedStorage.RemoteEvents.RoleEvent
roleModule.roleSelector = function(player)
local playerGui = player:WaitForChild("PlayerGui")
local RoundGui = playerGui:WaitForChild("RoundGui")
local RoleFrame = RoundGui.RoleFrame
warn("display roles")
roleEvent:FireClient(player)
end
return roleModule
--- ON CLIENT ---
local roleEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("RoleEvent")
local player = game.Players.LocalPlayer
roleEvent.OnClientEvent:Connect(function(player)
local roundGui = player:WaitForChild("PlayerGui"):WaitForChild("RoundGui")
roundGui.RoleFrame.Visible = true
end)