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

Help with GUI creation via RemoteEvent?

Asked by
waifuSZN 123
7 years ago
Edited 7 years ago
local Players = game:GetService("Players")
local SpawnLocations = workspace.SpawnLocations
local requiredPlayers = 15
local i = 1

Players.CharacterAutoLoads = false

Players.PlayerAdded:Connect(function(Player)
    Player.RespawnLocation = SpawnLocations[i] -- Assign new Player to a Spawn
    i = i + 1
    Player:LoadCharacter()
end)

local event = game.ReplicatedStorage.RemoteEvent
event.Name = "playercountGUI"
event.Parent = game.Workspace

while i ~= requiredPlayers do
    event.OnServerEvent:connect(function()  

    end)
end


while i ~= requiredPlayers do
    local screenGui = Instance.new("ScreenGui")
    screenGui.Parent = script.Parent
    local textLabel = Instance.new("TextLabel")
    textLabel.Parent = screenGui
    textLabel.Position = UDim2.new(0, 495, 0, 25)
    textLabel.Size = UDim2.new(0, 150, 0, 50)
    textLabel.BackgroundColor3 = BrickColor.Black().Color
    textLabel.BackgroundTransparency = 0.5
    textLabel.Font = Enum.Font.ArialBold
    textLabel.Fontsize = Enum.FontSize.Size18
    textLabel.Text = "Players: " .. i
    textLabel.TextColor3 = BrickColor.White().Color
end

The first part of code defines the event, while the second part of the code is the event I have coded.

My issue is I have absolutely NO IDEA how to transfer the variable i between the event and the code.

Please help. (This is also my first time creating a RemoteEvent.)

0
Is this the entirety of the code, on both clientside and server-side? `i` is never defined, here. Pyrondon 2089 — 7y
0
No, but I can post everything. waifuSZN 123 — 7y
0
Posted the whole code waifuSZN 123 — 7y
0
At no point during this code are you firing the event. You have created it but you're not activating it. Foreshadowed_Dawn 4 — 7y
View all comments (2 more)
0
I'm unsure how to activate it. waifuSZN 123 — 7y
0
I may be a little late, but to fire the event to the server, use :FireServer() on the LocalScript Mayk728 855 — 7y

Answer this question