Debris:AddItem() throwing error

I guess they could try just putting v, I didnt figure it would work.

Yeah v.Parent and v both get the same errors:

Container is not a valid member of Model "Workspace.Carrot"

I see it must be line 28:

if v:WaitForChild("Container"):WaitForChild("plrInstance") then

and you might wanna change line 29 too

I get the error:

Infinite yield possible on 'Workspace.Carrot.Container:WaitForChild("plrInstance")'

I was thinking because it’s in a .Touched event, it fires multiple times, so when checking for the value, it’s not there, thus erroring out.

1 Like

looks like ‘plrInstance’ doesn’t exist inside the container
infinite yield means it’s waiting for something that isn’t there or doesn’t exist

yes that could be it I suggest adding a debounce

Like this?

	elseif hit.Name == "Main" and not debounce then
		plr = plrs:GetPlayerFromCharacter(hit.Parent.Parent)
		debounce = true
		plr.stats.Ingredients.Value += (script.Parent.Amount.Value * plr.stats.IngredientMultiplier.Value)
		
		local plrInstance = Instance.new("StringValue")
		plrInstance.Name = "plrInstance"
		plrInstance.Value = plr.Name
		plrInstance.Parent = Carrot
		
		UpdateClient:FireClient(plr, "Carrot")
	end
1 Like

exactly, and you migth wanna set the debounce false after updateclient so other players can also pick it up

Yeah nothing seems to work this is very unfortunate

I’m assuming this works but since i do not have the whole server script i guess just fiddle around with this idea:

Carrot server code:

local _playersWhoPickedUp = {}
-- When a player leaves remove from table
plr.PlayerRemoving:Connect(function(player)
	if _playersWhoPickedUp[player] then
		_playersWhoPickedUp[player] = nil
	end
end)

elseif hit.Name == "Main" then
	plr = plrs:GetPlayerFromCharacter(hit.Parent.Parent)
	
	if _playersWhoPickedUp[plr] then return end
	
	_playersWhoPickedUp[plr] = true
	plr.stats.Ingredients.Value += (script.Parent.Amount.Value * plr.stats.IngredientMultiplier.Value)
	
	UpdateClient:FireClient(plr, Carrot)
end

Client code:

local Magnet = script.Parent

local back = Magnet.M.Back
local Front = Magnet.M.Front

local Speed = 15

local Equip = game:GetService("ReplicatedStorage").MagnetEquip

local TS = game:GetService("TweenService")
local info = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local UpdateClient = game:GetService("ReplicatedStorage").UpdateClient

local plr = game.Players.LocalPlayer

local Debris = game:GetService("Debris")

Magnet.Equipped:Connect(function()
	--plr.PlayerScripts.ORBITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT.Trail.Enabled = true
end)

UpdateClient.OnClientEvent:Connect(function(ingredientInstance)
	local HRP = plr.Character.HumanoidRootPart
	local tween = TS:Create(ingredientInstance:WaitForChild("Container"), info, {CFrame = CFrame.new(HRP.Position)})

	tween:Play()
	tween.Completed:Wait()
	Debris:AddItem(ingredientInstance, 0.2)
end)

task.spawn(function()
	while true do
		for i = 0,1,0.001*Speed do
			back.Color = Color3.fromHSV(i, 1, 1)
			wait()
		end
	end
end)