Hey i think i have fixed your problem.
First we will need a variable for the player: (make sure this is a Local Script)
local player = game.Players.LocalPlayer
Now we can do the full code!
First lets see the code you alredy have:
local examplePart = game.Workspace.examplePart
local exampleTool = player.Backpack.ThisIsExample1
local exampleToolA = player.ReplicatedStorage.ThisIsExample2
examplePart.Touched:Connect(onTouch)
exampleToolA.Parent.Equipped:connect(function()
print(omg its equipped lol)
exampleTool.Parent.Unequipped:connect(function()
print(omg its unequipped lol)
end)
Ok now its the part where the magic happends.
There's a way that you can force the tool equipment, its using Humanoid:EquipTool
So your script should look like this:
local player = game.Player.LocalPlayer
examplePart.Touched:Connect(onTouch)
Humanoid:EquipTool(exampleTool)
end
exampleToolA.Parent.Equipped:connect(function()
print(omg its equipped lol)
end
exampleTool.Parent.Unequipped:connect(function()
print(omg its unequipped lol)
end)
Unfortunatly idk if there's a way to unequip a tool using a script :/
For more information about this subject, check this article
I hope this works for you, if it doesn't send me a message!
(also if i spelled something wrong correct me, im portguese sry :/)
(and also im noob at scripting so it very probable that this doesn't work, but good luck)
4 comments
What is the error its giving to you? and you can't print string without using quotations marks (" "), try using this print code: print("omg its equipped lol")
And use :Connect() because :connect() is deprecated
And i think there are some "end" missing, because there are three functions and only one "end"
Also at line 6 you are conenecting to a function called ("onTouch") when there's no function with that name