Player Drops Tool too far away from themselves, How could I stop this?

I would the player to be able to drop the tool just infront of themselves instead of above and away from themselves. When I set the tools CFrame in my drop script It doesn’t do anything. I can tell this because when I remove that specific line It doesn’t affect the way the item is dropped.

https://gyazo.com/5e0259d4b389044638658d9fa9376997

I have tried changing the CFrame of the handle which just move the handle alone, in this case it does drop at the players position but it just falls through the world even though It can collide with other objects

Here are my 2 scripts for Server and Client

SERVER

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Dropped")

remoteEvent.OnServerEvent:Connect(function(player)
	
	local humanoid = player.Character:WaitForChild("HumanoidRootPart")
	if humanoid then
		
		local items = game.ReplicatedStorage.Items
		local item = player.Character:FindFirstChildWhichIsA("Tool")
		
		local tool = item:FindFirstChild("Handle")
		
		item.Parent = game.workspace
        item.Handle.CFrame = player.Character.HumanoidRootPart.CFrame
	end
end)

CLIENT

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Dropped")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

UserInputService.InputBegan:Connect(function(input, player)
	
	if input.UserInputType == Enum.UserInputType.Keyboard then
		if input.KeyCode == Enum.KeyCode.Q then
			
			remoteEvent:FireServer()
			
			
		end
	end
end)

Any solutions are much appreciated!

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Your script is fine, the reason it looks like it isn’t doing anything is because when the handle is set to the HumanoidRootPart’s CFrame, the tool gets too close to the character and the player picks it up again. Maybe try this instead.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Dropped")

remoteEvent.OnServerEvent:Connect(function(player)

	local humanoid = player.Character:WaitForChild("HumanoidRootPart")
	if humanoid then
		
		local items = game.ReplicatedStorage.Items
		local item = player.Character:FindFirstChildWhichIsA("Tool")

		local tool = item:FindFirstChild("Handle")

		item.Parent = game.workspace
		item.Handle.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-4)
	end
end)

I multiplied the CFrame so it goes a bit further away from the player.

2 Likes

Thank you very much, This works perfectly. Coincidentally I had just found another solution although my solution is more crude it can be an alternative to the following problem. For those Interested.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("Dropped")

remoteEvent.OnServerEvent:Connect(function(player)
	
	local humanoid = player.Character:WaitForChild("HumanoidRootPart")
	if humanoid then
		
		local items = game.ReplicatedStorage.Items
		local item = player.Character:FindFirstChildWhichIsA("Tool")
		
		
		local tool = item:Clone()
		tool.Handle.CanCollide = true
		tool.Handle.CFrame = humanoid.CFrame + (humanoid.CFrame.LookVector * Vector3.new(2,2,2))
		tool.Parent = game.workspace
		
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.