Script is not detecting

I tried making a pickup system, but the script is not detecting if the block is in the player or not. It was suppose to be whenever you activate the proximity prompt it makes a block follow u but when you click a GUI it stops the block from following you.
This is the script I made

		while wait() do
			if currentSubject.Parent == plr.Character then
				currentSubject.Position = Vector3.new(plr.Character:WaitForChild("UpperTorso").Position.X, plr.Character:WaitForChild("UpperTorso").Position.Y, plr.Character:WaitForChild("UpperTorso").Position.Z-2)
				currentSubject.Rotation = plr.Character:WaitForChild("UpperTorso").Rotation
			elseif currentSubject.Parent ~= plr.Character then
				print("dropped block")
			end

		end

I’ve tried multiple things but it still doesn’t work. Please reply if you know how to fix this.

try this

script.Parent.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		currentSubject.Position = Vector3.new(plr.Character:WaitForChild("UpperTorso").Position.X, plr.Character:WaitForChild("UpperTorso").Position.Y, plr.Character:WaitForChild("UpperTorso").Position.Z-2)
		currentSubject.Rotation = plr.Character:WaitForChild("UpperTorso").Rotation
	elseif currentSubject.Parent ~= plr.Character then
		print("dropped block")
end

It was suppose to be whenever u activate the proximity prompt it makes a block follow u but when u click a GUI it stops the block from following u

You can use ProximityPrompt.Triggered to fire an event that’d make that brick follow you.
I’d recommend you insert a BodyGyop and BodyPosition into your brick to help with stability.

I’ve made a quick [and not the best] way to do that -

image

Of course you could put the ‘follow’ brick in RS, and use remote events alongside gui buttons to spawn/hide the brick on the player.

My bad, drag The BodyGyro and Position into the ‘follow’ brick

Result:

robloxapp-20220316-1402359.wmv (2.0 MB)

You can play with the BodyGyro and Position if you want.

Yes, but what I made is that when u activate the proximityprompt it moves the block parent to the player chracter and then I made a gui that when u click it removes it from the player character and change its parent to workspace, but for some reason my script is not detecting that the parent of the block is not the player character.