#(SOLVED)GUI button.MouseButton1Click not firing for no specified reason please help

28 messages · Page 1 of 1 (latest)

glossy sapphire
#

what

zinc escarp
#

idk

#

why it was deleted

glossy sapphire
#

send script

#

and error

zinc escarp
#

no errors

#

making a spectate for when players die

glossy sapphire
#

are u doing it in a localscript

zinc escarp
#

no zindex shenanigans

#

yes

#

local plr = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

local plrSelected = 1
local playerList = game.Players:GetPlayers()

local function UpdatePlayerList()
    playerList = game:GetService("Players"):GetPlayers()
    table.remove(playerList,table.find(playerList,plr))
end

local function UpdateCamSubject(subject)
    print(subject)
    plr.PlayerGui.SpectateScreenGui.PlayerNameTag.Text = subject.Name
    cam.CameraSubject = subject.Character.HumanoidRootPart
end

UpdatePlayerList()
game.Players.PlayerAdded:Connect(UpdatePlayerList)
game.Players.PlayerRemoving:Connect(UpdatePlayerList)

plr.PlayerGui.SpectateScreenGui.NextPlr.Activated:Connect(function()
    print("next")
    plrSelected += 1
    if plrSelected > #playerList then
        plrSelected = 1
    end
    print(plrSelected)
    UpdateCamSubject(playerList[plrSelected])
    print("cam updated")
end)

plr.PlayerGui.SpectateScreenGui.PrevPlr.Activated:Connect(function()
    print("previous")
    plrSelected -= 1
    if plrSelected < 1 then
        plrSelected = #playerList
    end
    UpdateCamSubject(playerList[plrSelected])
    print("cam updated")
end)

plr.PlayerGui.SpectateScreenGui.ReturnToLobby.Activated:Connect(function()
    game.Players.LocalPlayer:Kick("no lobby rn, sry")
end)

rs.Events.ActivateSpectating.Event:Connect(function()
    UpdateCamSubject(playerList[plrSelected])
end)```
#

i used both activated and mousebutton1clicked already

zinc escarp
#

i guess no one knows how to fix this lol

#

if i move rs.Events.ActivateSpectating.Event:Connect(function() UpdateCamSubject(playerList[plrSelected]) end) to before the gui activated connect events then it works for one input and then it does not fire any other input events

#

why would this happen

#

for some reason it either goes through the event once and the script somehow stops working or the script is getting stuck on the function somehow

#

most likely that it goes down like a list and doesnt check for other inputs after the activated event

#

still no errors

#

nvm

#

for some reason it doesnt work if i wait too long???

#

confused on whats happening

#

GUI button.MouseButton1Click not firing for no specified reason please help

#

ive narrowed down the problem

#

it works perfectly fine but then stops working after an amount of time

zinc escarp
#

fixed it

#

turns out that my custom character loader was causing the problem by turning character to nil and destroying it

#

i guess GUI wont work when the player character doesnt exist

#

(SOLVED)GUI button.MouseButton1Click not firing for no specified reason please help