BindableEvent 在字符重置时解除绑定
BindableEvent unbinding on character reset
所以,我有一个我需要使用的 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 事件处理程序。
所以,我有一个我需要使用的 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 事件处理程序。