(Local) checks if player has tool equipped:
local newTool = plr.Backpack:WaitForChild("MorsMachina")
--
local function equip(input, gp)
if not gp then
if input.KeyCode == Enum.KeyCode.R then
if alive then
if newTool.Parent == char then
unequip:FireServer(newTool)
else
newTool.Parent = char
equipRemote:FireServer(newTool)
end
end
end
end
end
uis.InputBegan:Connect(equip)
(Server) Gets items of the newTool from Module Script
(Below) and passes to :FireAllClients
but if player dies and tries equipping, it doesn’t work.
local function equipFunc(plr, tool)
if isDead then return end
local items = itemRetrieve.getItems(tool) --ModuleScript (below)
--
equip:FireAllClients(plr, items)
end
--
local function unequipFunc(plr, tool)
if isDead then return end
local items = itemRetrieve.getItems(tool) --ModuleScript (below)
--
unequip:FireAllClients(plr, items, tool)
end
Module Script inside of the script above that returns the error message after player is dead:
local RetrieveItems = {}
RetrieveItems.__index = RetrieveItems
--
function RetrieveItems.getItems(tool)
local tab = setmetatable({}, RetrieveItems)
--
print(tool:GetDescendants())
tab.reloadTime = 4.2
tab.maxDist = 500
tab.handle = tool.Handle
tab.leftSwitches = tool.Handle.Switches.LeftSwitches --After player dies, errors
tab.rightSwitches = tool.Handle.Switches.RightSwitches
--
tab.cells = tool.Handle.Barrel.Cells
--
tab.barrelhole = tool.Handle.Barrel.BarrelHole
return tab
end
--
return RetrieveItems
Error message if player dies with tool equipped:
LeftSwitches is not a valid member of Folder "lezilune.MorsMachina.Handle.Switches
Error message if player dies with tool unequipped:
The Parent property of MorsMachina is locked, current parent: NULL, new parent lezil