hello I’ve tried made that handles tool drop, picking up, and tool motor 6ds, but I’m having a problem where when equipping the tool the tool seems to lag to the player from the last place it was unEquipped.
note that this is happening for every tool in the game which is why i will include later in this post scripts that handle these serverside scripts that handle said tools
see here:
here are some scripts that may cause problems
– motor6d script that also handle equip animation
-- Server Script
local returnable = {
"punch"
}
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D")
local rightArm = char:WaitForChild("Right Arm")
M6D.Part0 = rightArm
M6D.Parent = rightArm
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
local tool = child
if table.find(returnable, tool.Name) then
return
end
end
if child:IsA("Tool") and child:FindFirstChild("bodyAttach") then
local humanoid = char:FindFirstChild("Humanoid")
local tool = child
local bodyAttach = child.bodyAttach
local equipAnim = bodyAttach:FindFirstChild("equipAnim")
local loadequip = humanoid:LoadAnimation(equipAnim)
for _, val in ipairs(returnable) do
if tool.Name == val or char:FindFirstChild(val) then
return
end
end
tool.Equipped:Connect(function()
loadequip:Play()
M6D.Part1 = bodyAttach
end)
tool.Unequipped:Connect(function()
loadequip:Stop()
M6D.Part1 = nil
end)
end
end)
end)
end)
– drop and pick up script
local collectionService = game:GetService("CollectionService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local mechanics = replicatedStorage:WaitForChild("mechanics")
local canBeStolen = collectionService:GetTagged("canBeStolen")
local notifyOnServerEvent = mechanics:WaitForChild("notifications"):WaitForChild("NotifyOnServer")
local allowedTeam = "robbers"
local function createPrompt(item)
local object = item:FindFirstChild("object")
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "pick up " .. item.Name
prompt.MaxActivationDistance = 5
prompt.RequiresLineOfSight = false
prompt.HoldDuration = 2
prompt.Style = Enum.ProximityPromptStyle.Custom
prompt.Parent = object
local function updatePromptVisibility(player)
if player.Team and player.Team.Name == allowedTeam then
prompt.Enabled = true
else
prompt.Enabled = false
end
end
game.Players.PlayerAdded:Connect(function(player)
updatePromptVisibility(player)
player:GetPropertyChangedSignal("Team"):Connect(function()
updatePromptVisibility(player)
end)
end)
prompt.Triggered:Connect(function(player)
local character = player.Character or player.Character:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local playerStats = player:FindFirstChild("playerStats")
local otherStats = player:FindFirstChild("otherStats")
local maxInventory = playerStats:WaitForChild("maxInventorySpace")
local currentCarryValue = otherStats:WaitForChild("currentInventorySpace")
if currentCarryValue.Value < maxInventory.Value then
object.Anchored = false
prompt:Destroy()
currentCarryValue.Value += 1
-- humanoid.WalkSpeed -= item:FindFirstChild("additionalWalkSpeed").Value
notifyOnServerEvent:FireClient(player, "picked up " .. item.Name, "positive")
item.Parent = player.Backpack
return
end
if currentCarryValue.Value == maxInventory.Value then
notifyOnServerEvent:FireClient(player, "not enough carrying space", "negative")
end
end)
end
for _, item in ipairs(canBeStolen) do
createPrompt(item)
end
-- drop
local items = mechanics:WaitForChild("items")
local dropEvent = items:WaitForChild("dropItem")
dropEvent.OnServerEvent:Connect(function(player)
local character = player.Character or player.Character:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local playerStats = player:FindFirstChild("playerStats")
local otherStats = player:FindFirstChild("otherStats")
local maxInventory = playerStats:WaitForChild("maxInventorySpace")
local currentCarryValue = otherStats:WaitForChild("currentInventorySpace")
local tool = character:FindFirstChildWhichIsA("Tool")
if tool and collectionService:HasTag(tool, "canBeStolen") then
local object = tool:FindFirstChild("object")
currentCarryValue.Value -= 1
--humanoid.WalkSpeed += tool:FindFirstChild("additionalWalkSpeed").Value
tool.Parent = workspace
object.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
object.Anchored = true
createPrompt(tool)
notifyOnServerEvent:FireClient(player, "dropped " .. tool.Name, "positive")
end
end)
I’ve tried setting the “object” a handle like reference inside the tool to massless. I’ve even tried setting anchored to false, but nothing has worked. any help is appreciated!