Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to force a player to drop a tool?

I am trying to make a Mjolnir, but I want it so that only I can equip it. If anyone else tries the weapon gets removed. But I dont know how to do this. Here is what I tried

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




--Buffs--

tool.Equipped:connect(function()
	if name ==("turbomegapower1234") then
		Humanoid.MaxHealth = 100000
		Humanoid.Health = 100000
		Humanoid.WalkSpeed = 100
	else
		Mjolnir:Destroy()
		
	end    
end)

--Removing Buffs --

tool.Unequipped:connect(function()
	if name ==("turbomegapower12345") then
		Humanoid.MaxHealth = 100
		Humanoid.Health = 100
		Humanoid.WalkSpeed = 16
	end
end)

1 comment

0

I'm not too good at scripting, but from what I see you haven't specified where your name is located (line 12 and 25)

1 answer

✓ Accepted answer
repeat wait() until game.Players.LocalPlayer.Character:IsDescendantOf(workspace)

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

--Buffs--

tool.Equipped:connect(function()
    if (name == "turbomegapower1234") then -- make sure name is also inside the parenthesis
        Humanoid.MaxHealth = math.huge -- a big value, or you can stick to 100,000
        Humanoid.Health = Humanoid.MaxHealth
        Humanoid.WalkSpeed = 100
    else
        tool:Destroy() -- use 'tool' variable instead
    end    
end)

--Removing Buffs --

tool.Unequipped:connect(function()
    if (name == "turbomegapower12345") then
        Humanoid.MaxHealth = 100
        Humanoid.Health = 100
        Humanoid.WalkSpeed = 16
    end
end)

1 comment

0

oh ok thx

This discussion is preserved as it was. New answers, comments, and votes are closed.