#event ignored by the script

1 messages · Page 1 of 1 (latest)

pastel whale
#

server side

for i = 1, #players do
        CAMERA:FireClient(players[i])
        CLOSEGUI:FireClient(players[i])
    end

client side

CLOSEGUI.OnClientEvent:Connect(function()
    local frame = game:GetService("Players").LocalPlayer.PlayerGui.Main.Frame
    local P1 = frame.P1:GetChildren()
    local P5 = frame.P5:GetChildren()
    local P6 = frame.P6:GetChildren()
    
    for i = 1, 2 do
        P5[i].Visible = false
        P6[i].Visible = false
    end
    for i = 1, #P1 do
        P1[i].Visible = true
    end
    
    frame.Visible = false
end)

CAMERA.OnClientEvent:Connect(function()
    local character = game:GetService("Players").LocalPlayer.Character
    if character then
        local root = character:FindFirstChild("HumanoidRootPart")
        if root then
            local characterCFrame = root.CFrame
            local cameraOffset =  characterCFrame.LookVector * 9 + characterCFrame.UpVector * 6
            local cameraPosition = characterCFrame.Position + cameraOffset

            local pos = Instance.new("Part")
            pos.Anchored = true
            pos.CFrame = CFrame.new(cameraPosition)
            pos.Transparency = 1
            pos.Parent = workspace

            workspace.CurrentCamera.CameraSubject = pos
        end
    end
end)

players is a table of players

problem: CAMERA event is completely ignored by the server script, prints inside it arent shown, CLOSEGUI event is executed normally

if i put the function from CAMERA event inside CLOSEGUI, it works, but i dont want to link both on the same event
did the opposite and put both functions on CAMERA event, nothing executed
fired CLOSEGUI before CAMERA, same problem
changed CAMERA event name to something else, still nothing
fired CAMERA event from another FOR loop, still nothing

restive mirage
#
CAMERA.OnClientEvent:Connect(function()
    local character = game:GetService("Players").LocalPlayer.Character
    if character then
        local root = character:FindFirstChild("HumanoidRootPart")
        if root then
            local characterCFrame = root.CFrame
            local cameraOffset =  characterCFrame.LookVector * 9 + characterCFrame.UpVector * 6
            local cameraPosition = characterCFrame.Position + cameraOffset

            local pos = Instance.new("Part")
            pos.Anchored = true
            pos.CFrame = CFrame.new(cameraPosition)
            pos.Transparency = 1
            pos.Parent = workspace

            workspace.CurrentCamera.CameraSubject = pos
        end
    end
end)```
#

just a tip, you should always have a player variable

#

main issue i'm seeing is that you're not adding a player.CharacterAdded:Wait() after

#
CAMERA.OnClientEvent:Connect(function()
    local player = game:GetService("Players").LocalPlayer
    local character = player.Character or player.CharacterAdded:Wait()

    if character then
        local root = character.PrimaryPart or character:WaitForChild("HumanoidRootPart")

        if root then
            local characterCFrame = root.CFrame
            local cameraOffset =  characterCFrame.LookVector * 9 + characterCFrame.UpVector * 6
            local cameraPosition = characterCFrame.Position + cameraOffset

            local pos = Instance.new("Part")
            pos.Anchored = true
            pos.CFrame = CFrame.new(cameraPosition)
            pos.Transparency = 1
            pos.Parent = workspace

            workspace.CurrentCamera.CameraSubject = pos
        end
    end
end)```
restive mirage
#

try to remove all if statements

#

and add a load ton of prints

pastel whale
#

k

pastel whale
# restive mirage and add a load ton of prints
for i = 1, #players do
    print("for loop executed")
    CAMERA:FireClient(players[i])
    CLOSEGUI:FireClient(players[i])
end
        print("event fired")
    local player = game:GetService("Players").LocalPlayer
    local character = player.Character
    local root = character.PrimaryPart or character:WaitForChild("HumanoidRootPart")
    
    print("setting camera position")
    local characterCFrame = root.CFrame
    local cameraOffset =  characterCFrame.LookVector * 9 + characterCFrame.UpVector * 6
    local cameraPosition = characterCFrame.Position + cameraOffset
    
    print("setting camera subject")
    local pos = Instance.new("Part")
    pos.Anchored = true
    pos.CFrame = CFrame.new(cameraPosition)
    pos.Transparency = 1
    pos.Parent = workspace
    
    print("camera event done")
    workspace.CurrentCamera.CameraSubject = pos
#

its weird

#

cuz the CLOSEGUI is executed

#

but the console is empty

restive mirage
#

what if you do

#
for _, player in players do```
pastel whale
restive mirage
#

send whole code

pastel whale
#

cuz the client is complete

restive mirage
#

entire

pastel whale
#

lemme send

pastel whale
# restive mirage entire
COMECARF.Event:Connect(function(jogs)
    local mesas = game:GetService("ServerStorage").Mesas
    local mesaI
    if mesas.a.Value == false then
        mesas.a.Value = true
        mesaI = "a"
    elseif mesas.b.Value == false then
        mesas.b.Value = true
        mesaI = "b"
    elseif mesas.c.Value == false then
        mesas.c.Value = true
        mesaI = "c"
    elseif mesas.d.Value == false then
        mesas.d.Value = true
        mesaI = "d"
    elseif mesas.e.Value == false then
        mesas.e.Value = true
        mesaI = "e"
    elseif mesas.f.Value == false then
        mesas.f.Value = true
        mesaI = "f"
    elseif mesas.g.Value == false then
        mesas.g.Value = true
        mesaI = "g"
    elseif mesas.h.Value == false then
        mesas.h.Value = true
        mesaI = "h"
    end

    local mesaT
    if #jogs == 2 then
        mesaT = "mesa1"
    elseif #jogs == 4 then
        mesaT = "mesa2"
    elseif #jogs == 6 then
        mesaT = "mesa3"
    end
    
    local mesaF = workspace:FindFirstChild(mesaT):Clone()
    local pos = CFrame.new(game:GetService("ServerStorage").MesasP:FindFirstChild(mesaI).Value)
    mesaF:PivotTo(pos * CFrame.Angles(0, 0, math.rad(-90)))
    mesaF.Name = mesaI
    mesaF.Parent = workspace
    
    local jogsF = {}
    for i = 1, #jogs do
        jogsF[i] = game:GetService("Players"):GetPlayerByUserId(tonumber(jogs[i].Name))
    end
    
    local jogsT = jogsF
    local time1 = {}
    local time2 = {}
    for i = 1, #jogs do
        local sorteio
        sorteio = jogsT[math.random(1, #jogsT)]
        if i % 2 ~= 0 then
            table.insert(time1, sorteio)
        elseif i % 2 == 0 then
            table.insert(time2, sorteio)
        end
        table.remove(jogsT, table.find(jogsT, sorteio))
    end
#
if #jogs == 2 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
    elseif #jogs == 4 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.b1.Seat:Sit(time1[2].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
        mesaF.b2.Seat:Sit(time2[2].Character.Humanoid)
    elseif #jogs == 6 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.b1.Seat:Sit(time1[2].Character.Humanoid)
        mesaF.c1.Seat:Sit(time1[3].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
        mesaF.b2.Seat:Sit(time2[2].Character.Humanoid)
        mesaF.c2.Seat:Sit(time2[3].Character.Humanoid)
    end
    
    for _, player in jogsF do
        print("for loop executed")
        CAMERASET:FireClient(player)
        FECHARGUI:FireClient(player)
    end
end)
restive mirage
#
COMECARF.Event:Connect(function(jogs)
    local mesas = game:GetService("ServerStorage").Mesas
    local mesaI
    if mesas.a.Value == false then
        mesas.a.Value = true
        mesaI = "a"
    elseif mesas.b.Value == false then
        mesas.b.Value = true
        mesaI = "b"
    elseif mesas.c.Value == false then
        mesas.c.Value = true
        mesaI = "c"
    elseif mesas.d.Value == false then
        mesas.d.Value = true
        mesaI = "d"
    elseif mesas.e.Value == false then
        mesas.e.Value = true
        mesaI = "e"
    elseif mesas.f.Value == false then
        mesas.f.Value = true
        mesaI = "f"
    elseif mesas.g.Value == false then
        mesas.g.Value = true
        mesaI = "g"
    elseif mesas.h.Value == false then
        mesas.h.Value = true
        mesaI = "h"
    end

    local mesaT
    if #jogs == 2 then
        mesaT = "mesa1"
    elseif #jogs == 4 then
        mesaT = "mesa2"
    elseif #jogs == 6 then
        mesaT = "mesa3"
    end
    
    local mesaF = workspace:FindFirstChild(mesaT):Clone()
    local pos = CFrame.new(game:GetService("ServerStorage").MesasP:FindFirstChild(mesaI).Value)
    mesaF:PivotTo(pos * CFrame.Angles(0, 0, math.rad(-90)))
    mesaF.Name = mesaI
    mesaF.Parent = workspace
    
    local jogsF = {}
    for i = 1, #jogs do
        jogsF[i] = game:GetService("Players"):GetPlayerByUserId(tonumber(jogs[i].Name))
    end
    
    local jogsT = jogsF
    local time1 = {}
    local time2 = {}
    for i = 1, #jogs do
        local sorteio
        sorteio = jogsT[math.random(1, #jogsT)]
        if i % 2 ~= 0 then
            table.insert(time1, sorteio)
        elseif i % 2 == 0 then
            table.insert(time2, sorteio)
        end
        table.remove(jogsT, table.find(jogsT, sorteio))
    end
#
if #jogs == 2 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
    elseif #jogs == 4 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.b1.Seat:Sit(time1[2].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
        mesaF.b2.Seat:Sit(time2[2].Character.Humanoid)
    elseif #jogs == 6 then
        mesaF.a1.Seat:Sit(time1[1].Character.Humanoid)
        mesaF.b1.Seat:Sit(time1[2].Character.Humanoid)
        mesaF.c1.Seat:Sit(time1[3].Character.Humanoid)
        mesaF.a2.Seat:Sit(time2[1].Character.Humanoid)
        mesaF.b2.Seat:Sit(time2[2].Character.Humanoid)
        mesaF.c2.Seat:Sit(time2[3].Character.Humanoid)
    end
    
    for _, player in jogsF do
        print("for loop executed")
        CAMERASET:FireClient(player)
        FECHARGUI:FireClient(player)
    end
end)
restive mirage
#

and where's the for i = 1, #players loop

pastel whale
#

players is jogsF

pastel whale
#

sorts the players in 2 teams

#

then remove all gui on the players and change their camera subject

restive mirage
#

print jogsF before looping

pastel whale
restive mirage
#

so it's your logic thats broken

#

fix it

pastel whale
#

not an empty table, not even a print

restive mirage
#

awman

pastel whale
#

only if studio updated or something

restive mirage
#

e

#

add more prints

pastel whale
#

just opened output window and also nothing there

#

istg

pastel whale
#

not sure but maybe the bindable event is messing some things up

#

but still non sense cuz one event is fired perfectly

#

also tried inserting the camera function inside closing the gui with the help of an auxiliar variable, so i could fire the close gui passing "1" as parameter and check if auxiliar variable value == 1 then execute camera function

ornate cairnBOT
#

studio** You are now Level 5! **studio

pastel whale
#

that didnt worked too, everything but the IF is executed

#

if i remove the IF, it works

#

so far, the only way i can see to fix this problem is to merge both events into one and make another one without the CAMERA part

restive mirage
#

i gotta go

#

sorry

#

good luck on it though

pastel whale
#

🙏

#

thank you for your time

fathom timber