首页 > 解决方案 > BindableEvent 在字符重置时解除绑定

问题描述

所以,我有一个 BindableEvent 需要使用,但是当角色重置时,该事件无法再使用。即使重置后,我怎样才能让它 qork?这是我的代码:

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

标签: luaroblox

解决方案


如果您将 Bi​​ndAction 命令放入 StarterGUI 文件夹,它将正常工作。您甚至不需要 Died 事件处理程序。


推荐阅读