I've found a big part of the problem: For some reason, when I equip the tool ONLY after clicking on it, it teleports me to the tool situated in the REPLICATED STORAGE. It doesn't do this when I equip it after touching it, though
I have no clue what is causing this, it doesn't do that at all with other items
local Tool = script.Parent
local cd = Tool.Handle.ClickDetector
local enabled = true
cd.MouseClick:Connect(function(Player)
local Toolclone = game.ReplicatedStorage.Apple:Clone()
Toolclone.Parent = Player.Backpack
Tool:Destroy()
end)
function onActivated()
if not enabled then
return
end
enabled = false
local player = game.Players:GetPlayerFromCharacter(Tool.Parent)
if player then
local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
if humanoid then
humanoid.WalkSpeed = humanoid.WalkSpeed + 5
end
end
Tool.Handle.Eating:Play()
wait(0.8)
Tool:Destroy()
end
local Players = game:GetService("Players")
function onEquipped()
Tool.Handle.OpenSound:Play()
end
script.Parent.Activated:Connect(onActivated)
script.Parent.Equipped:Connect(onEquipped)
Updated script