I’m making a pickup script which works via ‘E’ to pick up. Everything works fine apart from the billboard GUI which goes above the item and the fact that it is possible to pick up multiple items at the same time if they are within the max distance radius. The billboard GUI flashes on and off with each movement, which is to do with the ‘else’ I put in. I tried using the double for loop and the if statements to prevent the multiple pick up, but this proved ineffective. I have no idea how to prevent the flashing on and off whilst still making sure the billboard GUI doesn’t stay if you are outside of the max distance.
Any help would be great.
I posted the script minus the variables since you can pretty much assume they’re all correct.
HandpickTool.Equipped:Connect(function()
UIS.InputBegan:Connect(function(input)
for _,fruit in pairs(CollectionService:GetTagged("FruitPick")) do
if fruit and (HumRP.Position - fruit.Position).magnitude < MaxDist and debounce then
for _,fruit2 in pairs(CollectionService:GetTagged("FruitPick")) do
if fruit2 and ((HumRP.Position - fruit.Position) - (HumRP.Position - fruit2.Position)).magnitude <= 0 then
debounce = false
FruitPickGUI.Enabled = true
FruitPickGUI.Adornee = fruit
if input.KeyCode == Enum.KeyCode["E"] then
local PAnimation = script:WaitForChild("PAnimation")
local PAnimationTrack = hum:LoadAnimation(PAnimation)
PAnimationTrack:Play()
HandPickRemote:FireServer(fruit, Inventory)
end
wait()
debounce = true
else
FruitPickGUI.Enabled = false
FruitPickGUI.Adornee = nil
end
end
end
end
end)
end)