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

FireAllClients only firing to one client?

Asked by 1 year ago

I have an Intermission GUI that is activated through a remote event, I used FireAllClients but can't seem to figure out why it's only firing one client. (See image below)

https://imgur.com/a/aBk0vni

Server:

-- Variables --

local rep = game:GetService("ReplicatedStorage")
local water = workspace.Water

local tp = workspace.TeleportPart
local tp2 = workspace.TeleportPart2

local intermission = rep:WaitForChild("Intermission")
local timer = rep:WaitForChild("Timer")

local obby = rep:WaitForChild("Obby")
local map = rep:WaitForChild("LaserTag")

local TweenService = game:GetService("TweenService")
local part = water

local players = game:GetService("Players")

local player = players:GetChildren()
local playercheck = rep:WaitForChild("PlayerCheck")

local Teleport = rep:WaitForChild("TP")
local Teleport2 = rep:WaitForChild("TP2")

local sword = rep:WaitForChild("Sword")

local laser = rep:WaitForChild("Laser")
local minimumPlayers = 1

----------------


-- Tween Service --

local info = TweenInfo.new(
    30,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.Out,
    0,
    true,
    5
)

local Goals = {
    Size = Vector3.new(91,40,91);
}

local tween = TweenService:Create(part, info, Goals)

-------------------



-- Functions --

function teleportPlayers()
    Teleport:FireAllClients()
end

function teleportPlayers2()
    Teleport2:FireAllClients()
end

function giveLaser()
    for i, v in pairs(game.Players:GetPlayers()) do
        local newLaser = laser:Clone()
        newLaser.Parent = v.Backpack
    end
end

function giveSword()
    for i, v in pairs(game.Players:GetPlayers()) do
        local newSword = sword:Clone()
        newSword.Parent = v.Backpack
    end
end

function removeSword()
    for i, v in pairs(game.Players:GetPlayers()) do
        if v.Backpack.Sword then
            v.Backpack.Sword:Destroy()
        elseif v.Character.Sword then
            v.Character.Sword:Destroy()
        end
    end
end

function removeLaser()
    for i, v in pairs(game.Players:GetPlayers()) do
        if v.Backpack.Laser then
            v.Backpack.Laser:Destroy()
        elseif v.Character.Laser then
            v.Character.Laser:Destroy()
        end
    end
end
---------------


while wait() do
    if #players:GetPlayers() >= minimumPlayers then
        while true do
            local num = math.random(3)
            if num == 1 then
                print("Game chosen: Sword Fight")
                intermission:FireAllClients()
                wait(34)
                timer:FireAllClients()
                teleportPlayers()
                giveSword()
                wait(60)
                removeSword()
            elseif num == 2 then
                print("Game chosen: Flood Escape")
                intermission:FireAllClients()
                local newObby = obby:Clone()
                newObby.Parent = workspace
                newObby:MoveTo(Vector3.new(2.5, 95.7, -9.5))
                wait(34)
                timer:FireAllClients()
                teleportPlayers()
                water.Transparency = 0.3
                water.CanTouch = true
                tween:Play()
                print("Water rising")
                wait(60)
                water.Transparency = 1
                water.CanTouch = false
                water.Size = Vector3.new(91, 1, 92)
                newObby:Destroy()
                teleportPlayers2()
            elseif num == 3 then
                print("Game chosen: Laser Tag")
                intermission:FireAllClients()
                local newmap = map:Clone()
                newmap.Parent = workspace
                newmap:MoveTo(Vector3.new(4.664, 81.7, 2.043))
                wait(32)                
                teleportPlayers()               
                wait(1) 
                giveLaser()
                timer:FireAllClients()
                wait(60)
                removeLaser()
                newmap:Destroy()
            end
            wait(1)
        end
    else
        playercheck:FireAllClients()
    end
end

Client:

local rep = game:GetService("ReplicatedStorage")

local intermission = rep:WaitForChild("Intermission")
local timer = rep:WaitForChild("Timer")

local playercheck = rep:WaitForChild("PlayerCheck")
local players = game:GetService("Players")

local allplayers = players:GetPlayers()
local tp = rep:WaitForChild("TP")

local tp2 = rep:WaitForChild("TP2")
local player = game.Players.LocalPlayer

timer.OnClientEvent:Connect(function()
    for count = 60, 0, -1 do
        script.Parent.Text = count
        wait(1)
    end
end)

intermission.OnClientEvent:Connect(function()
    for count = 30, 0, -1 do
        script.Parent.Text = "Intermission: "..count
        wait(1)
    end
end)

playercheck.OnClientEvent:Connect(function()
    script.Parent.Text = "Not enough players"
end)

tp2.OnClientEvent:Connect(function()
    for_, players = pairs(game.Players:GetChildren()) do
        player.Character.HumanoidRootPart.CFrame = workspace.TeleportPart2.CFrame
    end
end)

tp.OnClientEvent:Connect(function()
    for_, players = pairs(game.Players:GetChildren()) do
        player.Character.HumanoidRootPart.CFrame = workspace.TeleportPart.CFrame
    end
end)

Thanks in advance, Scryptio.

0
This looks very interesting, I'm assuming this is about dealing when someone is in the lobby? JerkDerekThe14alt 11 — 1y
0
Where is this localscript placed please? BeautifulAuraLover 371 — 1y
0
Yes, this is in a lobby. Scryptio 64 — 1y
0
The local script is in a TextLabel inside of StarterGui. Scryptio 64 — 1y

Answer this question