BindableEvent 解除字符重置时的绑定。

问题描述 投票:0回答:1

所以,我有一个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

lua roblox
1个回答
1
投票

如果你把你的BindAction命令放到StarterGUI文件夹中,它就会工作。你甚至不需要一个Died事件处理程序。

© www.soinside.com 2019 - 2024. All rights reserved.