BindableEvent解绑在角色重置时

我有一个需要使用的BindableEvent,但是当角色重置时,事件就不能再使用了。我该如何在重置后使其正常工作?以下是我的代码:

local CS=game:GetService("ContextActionService")
local Player=game:GetService("Players").LocalPlayer
CS:BindAction("Chat Focus",function()
    spawn(function() ChatBar:CaptureFocus() end)
    ChatBar.PlaceholderText = ""
end,false,Enum.KeyCode.Slash)
Player.Character:WaitForChild("Humanoid").Died:Connect(function()
    repeat wait(0.01) until Player.Character
    CS:BindAction("Chat Focus",function()
        spawn(function() ChatBar:CaptureFocus() end)
        ChatBar.PlaceholderText = ""
    end,false,Enum.KeyCode.Slash)
end)

非常感谢您的帮助:D

点赞
用户1296374
用户1296374

如果您将BindAction命令放入StarterGUI文件夹中,它将会正常工作。您甚至不需要一个Died事件处理程序。


如果您将`BindAction`命令放入`StarterGUI`文件夹中,它将会正常工作。您甚至不需要一个`Died`事件处理程序。
2020-05-05 05:55:20