Hello, so I’m making a custom hotbar. Everything works fine. But after I unbind the action(since the tool was gone) I cant seem to re-bind it. It prints, no errors. Any help is apreciated:
local CAS = game:GetService("ContextActionService")
local function EquipTool(ActionName, State)
if State == Enum.UserInputState.Begin then
local Tool = script.Parent.Tool.Value
if Tool ~= nil then
if Tool:IsA("Tool") and Tool.Parent == game.Players.LocalPlayer.Character or game.Players.LocalPlayer.Backpack then
if Tool.Parent == game.Players.LocalPlayer.Backpack then
Tool.Parent = game.Players.LocalPlayer.Character
elseif Tool.Parent == game.Players.LocalPlayer.Character then
Tool.Parent = game.Players.LocalPlayer.Backpack
end
else
CAS:UnbindAction("EquipWeapon" .. script.Parent.Name)
end
end
end
end
local EquipTool = CAS:BindAction("EquipWeapon" .. script.Parent.Name, EquipTool, false, script.Parent.Name)
print("Binded")
game.ReplicatedStorage.RemoteEvents.DeleteHotbarEvent.OnClientEvent:Connect(function(HotbarID)
if script.Parent.Name == tostring(HotbarID) then
print("Removing")
CAS:UnbindAction("EquipWeapon" .. script.Parent.Name)
script.Parent:Destroy()
end
end)
I really need help. Anyone’s help is appreciated!!!