Trouble with tool [FINALLY SOLVED]

I just edited my reply, so it is more clear what to do.

Ok thanks, I’ll try that! I tell you the results in a few minutes!

1 Like

Well here the results…


It gives me the tool a lot of times

1 Like

ok, I know how to fix this too.
just give me a moment to do it

Thank you very much! Have a good day!

1 Like

The multiple tools thing is happening because there is no cooldown, and when you touch the part you are actually touching it multiple times as you are moving, and you have many parts in the character.

do this instead:

script.Parent.Touched:Connect(function(part) -- check if the part has been touched, then run the function. The part is the part that touched this part
cooldown = false
	
	if part.Parent:FindFirstChild("Humanoid") and cooldown == false then -- check if the part has a sibling called "Humanoid" humanoid is only in characters and we are checking if cooldown is done.
        local tool = game.Workspace.GloveNameHere:Clone() --change "Workspace" to wherever your tool is and continue going down the children if it is in another thing, and change "Tool" to the name of your tool. This is cloning the tool
		tool.Parent = part.Parent -- put the tool in the players character, this makes it start equiped.
        cooldown = true
        wait(1) 
        cooldown = false
	end
	
end)

this will also add a cooldown for one second, so all the players do not flood the code. which can cause lag if your game is already laggy.

1 Like

Did this script work? I would like to know so that if it does not I can try to find a way that will work.

1 Like

I’ll tell you when I’ll be back of school! I don’t tried it for the moment.

Sorry for the late answer…

It didn’t work :confused:

I really am sorry, here, I edited the code I hope it works now:

script.Parent.Touched:Connect(function(part) -- check if the part has been touched, then run the function. The part is the part that touched this part
cooldown = false
	
	if part.Parent:FindFirstChild("Humanoid") then -- check if the part has a sibling called "Humanoid" humanoid is only in characters
        if cooldown == false then

             local tool = game.Workspace.GloveNameHere:Clone() --change "Workspace" to wherever your tool is and continue going down the children if it is in another thing, and change "Tool" to the name of your tool. This is cloning the tool
		     tool.Parent = part.Parent -- put the tool in the players character, this makes it start equiped.
             cooldown = true
            wait(1) 
            cooldown = false
        end
	end
	
end)

Also, If there are errors from the output please let me know what they are.


The variable “cooldown” is underlined is blue, is this an error?

Don’t be sorry you already helped a lot!

Still don’t work…

image

That means it wants you to change it to local.

local cooldown =

don’t do

cooldown =

Like this ?

1 Like

exactly

(extra characters, ignore this)

Begin logging the entire script line by line so like after the first line write

print(“Event called”)

and do this for every line (with different text) and share the output.

I totally forgot about these, the print checkpoints will help a lot

1 Like

Why do it underline in red?