Hello, I need help with a local script of mine. It is in a tool called Mjolnir, but for some reason the script is not working. When I click E it is supposed to make Mjolnir return to me. In the output it says there is an issue.
Here is what the output says:
15:30:19.545 - Infinite yield possible on 'Workspace:WaitForChild("Mjolnir")'
And it also says
15:30:20.517 - Something unexpectedly tried to set the parent of Mjolnir to NULL while trying to set the parent of Mjolnir. Current parent is turbomegapower12345.
and now here is my script
local Humanoid = game.Players.LocalPlayer.Character.Humanoid local Mjolnir = game.Players.LocalPlayer.Backpack:WaitForChild("Mjolnir") local name = game.Players.LocalPlayer.Name local tool = script.Parent local toolreturn = game.Workspace:WaitForChild("Mjolnir") --Buffs-- tool.Equipped:connect(function() if name ==("turbomegapower1234") then Humanoid.MaxHealth = 100000 Humanoid.Health = 100000 Humanoid.WalkSpeed = 100 else Mjolnir:Remove() end end) --Removing Buffs -- tool.Unequipped:connect(function() if name ==("turbomegapower12345") then Humanoid.MaxHealth = 100 Humanoid.Health = 100 Humanoid.WalkSpeed = 16 end end) --this section is the one I need help on!-- local player = game.Players.LocalPlayer local character = player.Character local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "e" then character.Humanoid:EquipTool(toolreturn) else end end)
Thank you for the help!
This is because you are using deprecated code and wrapping strings in brackets.
local plr = game:GetService("Players").LocalPlayer local mjolnir = plr.Backpack:WaitForChild"Mjolnir" local tool = script.Parent local toolReturn = game.Workspace.Mjolnir tool.Equipped:Connect(function(mouse) --Connect not :connect if plr.Name == 'turbomegapower12345' then -- no brackets plr.Character.Humanoid.WalkSpeed = 16 plr.Character.Humanoid.MaxHealth = 100000 plr.Character.Humanoid.Health = 100000 else mjolnir:Destroy() -- Destroy not Remove end end) tool.Unequipped:Connect(function() if plr.Name == 'turbomegapower12345' then plr.Character.Humanoid.WalkSpeed = 16 plr.Character.Humanoid.MaxHealth = 100 plr.Character.Humanoid.Health = 100 end end) function equipTool() --keydown is deprecated, make a function to bind with CAS plr.Character.Humanoid:EquipTool(toolReturn) end game:GetService('ContextActionService'):BindAction('EquipTool', --use this equipTool, false, Enum.KeyCode.E --you can set a variety of keys not only one key )