Grab/Drop System, drop not properly working

  1. What do you want to achieve?
    My grab/drop system is not working properly ANYMORE. I want that if you drop the meat part, it just lands on the ground like it always did.

  2. What is the issue?
    It doesn’t land infront of you anymore, it seems like it flings with lightspeed into space.

  3. What solutions have you tried so far?
    Okay so, I’ve been printing the magnitude between the humanoidrootpart and the meat to see if it is anywhere close, it’s around 17k studs away from the player model and I don’t even know how that is possible as it always worked, I never touched any scripts again since I finished this system. A few days back I testplayed and realized the dropping meat part is not working and I can’t seem to figure out what’s causing it. I’ve literally set the CFrame and position to the player’s paw but nothing helps at all…

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

My server script:

-----


local CanThrowBlock = false
local pickedup = game.ReplicatedStorage.Picked

local function Takeblock(plr, block)

	local weld = Instance.new("Weld")
	local char = plr.Character
	local jaw = char:WaitForChild("Jaw")
-----
	local humanoid = char:WaitForChild("Humanoid")
	local Carnivore = humanoid:GetAttribute("Carnivore")

	local Herbivore = humanoid:GetAttribute("Herbivore")

	local Omnivore = humanoid:GetAttribute("Omnivore")
	
	
	if Carnivore == true or Omnivore == true and pickedup.Value == false then
		block.Anchored = false
		weld.Parent = block
		weld.Part0 = block
		weld.Part1 = jaw
		block.CFrame = char.Jaw.CFrame 

		weld.Name = "BlockWeld"

		wait(1)
		CanThrowBlock = true
		pickedup.Value = true
	end
---------
end

local function ThrowBlock(plr, block)
	if CanThrowBlock == true and pickedup.Value == true then
		local weld = block:WaitForChild("BlockWeld")
		if weld:IsA("Weld") then
			weld:Destroy()
			block.CanCollide = false
			wait(1)
			block.Anchored = true
			pickedup.Value = false
		
			print(block.Position)
			print((block.Position - plr.Character.HumanoidRootPart.Position).Magnitude)
			
			end
		end
		CanThrowBlock = false
		pickedup.Value = false

end

game.ReplicatedStorage.TakeBlock.OnServerEvent:Connect(Takeblock)
game.ReplicatedStorage.ThrowBlock.OnServerEvent:Connect(ThrowBlock)

My local script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharachterAdded:Wait()
local uis = game:GetService("UserInputService")
local hum = char:WaitForChild("Humanoid")
local CanGrabBlock = true

local function Block(plr, block)
	if CanGrabBlock == true then
		CanGrabBlock = false
		game.ReplicatedStorage.TakeBlock:FireServer(plr, block)
		uis.InputBegan:Connect(function(input, gameProcessedEvent)
			if input.KeyCode == Enum.KeyCode.T then
				game.ReplicatedStorage.ThrowBlock:FireServer(plr, block)
				wait(1)
				CanGrabBlock = true
			end
		end)
	end
end

game.ReplicatedStorage.ClientBlock.OnClientEvent:Connect(Block)

And ofc the serverscript inside the meat:

script.Parent.ClickDetector.RightMouseClick:Connect(function(plr)
	game.ReplicatedStorage.ClientBlock:FireClient(plr, script.Parent)
end)

Video for showcase of the problem, as you can see in the output the last value is magnitude and is really high for no reason. I expect it to be around 2-4 :confused:

5 Likes

I appreciate any kind of help :pray:

1 Like

I scrolled through fast, is this intentional?

1 Like

Oh actually no, I’ll change it rn but at some point I had it set to true as well, doesn’t seem to make a difference but lemme try now rq!

You could anchor it before setting CanCollide to false

I’ll try right now, one second

If I do that, the meat part is anchored in the air where the jaw is, it should be anchored when it’s on the ground

anchor it when it touches the ground, just make sure to turn cancollide off only after anchoring it so it doesnt fall through the ground

Perhaps the tiger model is flinging the meat into space?

If nothing works, maybe putting the tiger and meat into different collision groups might do it as a last resort. Might not help though.

How would I check if terrain is touched as it doesn’t have something like .Touched?

Oh generally the tiger has collisions off, it just uses canTouch and it worked before too so I don’t think that would be much of a difference D:

Parts detect Touch with terrain. You just gotta check if what the part has hit is called “Terrain”. You could also just use your current wait(1) thingy

Ohh I get it! I wil try it now^^

local function ThrowBlock(plr, block)
	if CanThrowBlock == true and pickedup.Value == true then
		local weld = block:WaitForChild("BlockWeld")
		if weld:IsA("Weld") then
			weld:Destroy()
			
			block.Touched:Connect(function(hit)
				if hit.Name == "Terrain" then
					print(hit.Name)
					block.Anchored = true
					block.CanCollide = false
				end
			end)
			
			pickedup.Value = false
		
			print(block.Position)
			print((block.Position - plr.Character.HumanoidRootPart.Position).Magnitude)
			
			end
		end
		CanThrowBlock = false
		pickedup.Value = false

end

I edited the throw block function, though it doesn’t work it doesn’t even print the hit.Name so I assume it’s not running yet, I did something wrong here for sure haha

Or it doesn’t even touch the terrain at all, as it magically gets flung somewhere but doesn’t actually fall through the world

Instead of doing what you did above, do

local function CompleteHit()
	block.Anchored = true
	block.CanCollide = false
end

_G.ThingToDisconnect = block.Touched:Connect(function(hit)
	if hit.Name == "Terrain" then
		CompleteHit()
		_G.ThingToDisconnect:Disconnect()
	end
end)

^^you disconnect the Touched thing in the example above

2 Likes

ooo I’ll let you know if this worked!

Unfortunately it doesn’t waa, I will try to add a print statement rq to see if it runs

_G.ThingToDisconnect = block.Touched:Connect(function(hit)
				if hit.Name == "Terrain" then
					print("Touched")
					CompleteHit()
					_G.ThingToDisconnect:Disconnect()
				end
			end)

It doesn’t seem to run or hit the Terrain as “Touched” isn’t printed

local function CompleteHit()
	block.Anchored = true
	block.CanCollide = false
end

local ThingToDisconnect = block.Touched:Connect(function(hit)
	if hit.Name == "Terrain" then
		CompleteHit()
	end
end)

You can do it like this too

tried it too, doesn’t work… this is like the worst thing ever to fix :sob:

Do you have another idea? What if the part doesnt actually touch the terrain :thinking: