I'm trying to make an item dropping script, and it seems to be working. The only issue however is the fact that it doesn't go on the ground, and rather the players head.
Here are the scripts:
Localscript
local RS = game:GetService("ReplicatedStorage")
local drop = RS.DropTool
local pressed = false
local player = game.Players.LocalPlayer
local char = player.Character
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Z then
pressed = true
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Z then
pressed = false
end
end
game:GetService("UserInputService").InputEnded:connect(onKeyPress)
while wait() do
if pressed then
wait(0.5)
if pressed then
for _, v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
drop:FireServer(v.ToolName.Value, char["Right Leg"].Position)
end
end
end
end
end
Normal Script
local RS = game:GetService("ReplicatedStorage")
local drop = RS.DropTool
local function onGender(player, tool, position)
print(player.Name, tool, position)
local tool2 = player.Character[tool.."Tool"]
if tool2 then
local tool3 = game.ServerStorage[tool.."Workspace"]
tool2.Parent = game:GetService("ServerStorage")
tool3.Parent = workspace
tool3:MoveTo(position)
end
end
drop.OnServerEvent:Connect(onGender)
As stated earlier, the item (in the testing I'm using keys) goes on top of the players head, rather than under their foot as I hoped it would go.

2 comments
This is quite common, try moving it to the position, then moving it one unit forward. Then it should appear by the player, and not on top of them. If the problem still occurs try moving it one or two more units over. If that dosnt work i'm sorry i'm a noob scripter lol.
@melissa666666girl Thank you so much! That fixed it!