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 2 years 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
Can you show where you put the Server and Client scripts in the Explorer? Send the photo throught a link. T3_MasterGamer 2189 — 2y
0
respect to anyone who reads all 200+ lines of code ZeroToH3ro 82 — 2y
0
I don't want to say anything yet, but I think math.random(3) should be floored so it returns a number and not a decimal. chessebuilderman 18 — 2y

1 answer

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago

In case of that it only fires to one client! Try looping through all the players and firing to that client!

Here's a example!

for _, player in pairs(game:GetService("Players"):GetPlayers()) do
    if player then

        remoteEvent:FireClient(player) -- Next to the player! Do , and what you wanna send to the client!

    end
end
Ad

Answer this question