Hey there! I'm making a survival game where you can pick up items and throw/drop them, and I'm trying to fix this bug for the past 2 days where if you pick up and drop different items after another one, the MaxActivationDistance on the ProximityPrompt doesn't change, and stays 0 making it so that you can't pick it up anymore. I will give the script's name, location, type for more info.

Script Inside Block:

script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
	if game.ReplicatedStorage.CurrItem.Value == "" then
		game.ReplicatedStorage.CurrItem.Value = script.Parent.Name
		game.ReplicatedStorage.ClientBlock:FireClient(plr, script.Parent)
	end
end)

game.ReplicatedStorage.ReturnTrue.Event:Connect(function()
	if game.ReplicatedStorage.ItemLocation.Value == script.Parent.Name then
		script.Parent.ProximityPrompt.MaxActivationDistance = 5
	end
end)

The things inside the block are a ProximityPrompt, and a Normal Script, located in Workspace.

Script Inside ServerScriptService:

local CanThrowBlock = false

local function Takeblock(plr, block)
	if game.ReplicatedStorage.CurrItem.Value == block.Name then
		local weld = Instance.new("Weld")
		local Char = plr.Character
		local Torso = Char:WaitForChild("Torso")
		weld.Parent = Torso
		weld.Part0 = Torso
		weld.Part1 = block
		block.CFrame = Torso.CFrame
		block.Position = block.Position + Torso.CFrame.LookVector
		weld.Name = "BlockWeld"
		block.ProximityPrompt.MaxActivationDistance = 0
		block.CanCollide = false
		wait(.5)
		CanThrowBlock = true
	end
end

local function ThrowBlock(plr, block)
	if CanThrowBlock == true then
		local Char = plr.Character
		local Torso = Char:WaitForChild("Torso")
		local weld = Torso:WaitForChild("BlockWeld")
		game.ReplicatedStorage.ItemLocation.Value = block.Name
		game.ReplicatedStorage.ReturnTrue:Fire(plr)
		weld:Destroy()
		weld.Part1.CanCollide = true
		weld.Part1.Velocity = weld.Part1.CFrame.LookVector * 50
		game.ReplicatedStorage.CurrItem.Value = ""
		CanThrowBlock = false
	end
end

local function DropBlock(plr, block)
	if CanThrowBlock == true then
		local Char = plr.Character
		local Torso = Char:WaitForChild("Torso")
		local weld = Torso:WaitForChild("BlockWeld")
		game.ReplicatedStorage.ItemLocation.Value = block.Name
		game.ReplicatedStorage.ReturnTrue:Fire(plr)
		weld:Destroy()
		weld.Part1.CanCollide = true
		game.ReplicatedStorage.CurrItem.Value = ""
		CanThrowBlock = false
	end
end

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

Already said where located.

LocalScript inside StarterGui:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local hum = char:WaitForChild("Humanoid")
local anim1 = hum:LoadAnimation(script.HoldingAnim)
local anim2 = hum:LoadAnimation(script.ThrowAnim)
local anim3 = hum:LoadAnimation(script.DropAnim)
local CanGrabBlock = true
local tapped = false

uis.InputBegan:Connect(function(input, gameProcessedEvent)
	if tapped == true then
	game.ReplicatedStorage.ThrowBlock:FireServer(plr)
	anim1:Stop()
	wait(1)
	CanGrabBlock = true
	end
end)

function Block(plr, block)
	if CanGrabBlock == true then
		CanGrabBlock = false
		anim1:Play()
		game.ReplicatedStorage.TakeBlock:FireServer(plr, block)
		uis.InputBegan:Connect(function(input, gameProcessedEvent)
			local function keypressed(actionName, userInputState, inputObject)
				if userInputState == Enum.UserInputState.Begin then
					if input.KeyCode == Enum.KeyCode.R then
						game.ReplicatedStorage.ThrowBlock:FireServer(plr, block)
						anim1:Stop()
						anim3:Play()
						wait(1)
						CanGrabBlock = true
				end
					if input.KeyCode == Enum.KeyCode.E then
						game.ReplicatedStorage.DropBlock:FireServer(plr, block)
						anim1:Stop()
						anim2:Play()
						wait(1)
						CanGrabBlock = true
					end
				end
			end
			game.ContextActionService:BindAction("Throw", keypressed, true, Enum.KeyCode.R)
			game.ContextActionService:SetPosition("Throw", UDim2.new(.5,0,.25,0))
			game.ContextActionService:BindAction("Drop", keypressed, true, Enum.KeyCode.E)
			game.ContextActionService:SetPosition("Drop", UDim2.new(.10,0,.25,0))
		end)
	end
end

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

Already said the type, and location. Inside the LocalScript is 3 animations, but that doesn't matter I don't think.

There is multiple important events inside ReplicatedStorage, here they are.

ClientDrop (RemoteEvent), DropBlock (RemoteEvent), ReturnTrue (BindableEvent), TakeBlock (RemoteEvent), ThrowBlock (RemoteEvent)

There is StringValues in ReplicatedStorage also, so here's that

CurrItem, ItemLocation

I would greatly appreciate if this was fixed, it has made a hault to a game I've been developing. Thank you so much and even if you weren't planning on helping me, I appreciate you reading.

Thanks.