lua - 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
解决方案
如果您将 BindAction 命令放入 StarterGUI 文件夹,它将正常工作。您甚至不需要 Died 事件处理程序。
推荐阅读
- amazon-web-services - AWS Application Loadbalancer 和 Cognito 用户池,redirect_mismatch
- python - Tkinter button arguments
- batch-file - 从 .bat 文件调用时,.net 核心控制台应用程序未运行
- c# - The specified path, file name, or both are too long. C# Azure Chat bot error
- android - Retrofit 中的空对象引用
- opencv - 使用齐次变换的坐标变换期间的乘法顺序
- javascript - 将图像添加到 iframe 标签上的背景 youtube 视频
- java - BEA-160228 LoggerFactory Logback LoggerContext. Either remove Logback... Weblogic springboot
- unity3d - 为什么 Unity 中的 Physics2D Raycast 未检测到对象?
- firebase - 如何从firebase获取JSON数据,然后在角度6中使用它,firebase返回带有值标签的数据