So in my game enemies drop tools when you kill them, recently a system where proximity prompts pop up for certain tools so you can pick them up was implemented. The issue is that since the proximity prompt was added, the enemy only drops the tool one time even though i have its drop rate at 100%.
To be more specific, if i kill an enemy, he drops a tool. But if i kill him again he wont drop a tool even though the chance rate is 100%.
here is the code which the prompt was added into, any help would be appreciated.
if not reward.Stats:FindFirstChild("Prompt") or not reward.Stats.Prompt.Value then
obj.Disabled = true
end
end
end
dropBlock.Handle.CFrame = CFrame.new(position)
wait(.2)
local anchor = Instance.new("Part")
anchor.Name = "AnchorPart"
anchor.Size = Vector3.new(2, 2, 2)
anchor.Transparency = 1
anchor.Anchored = true
anchor.CanCollide = false
anchor.Parent = model
anchor.CFrame = CFrame.new(dropBlock.Handle.Position) * CFrame.new(0, 1.5, 0)
if player.Character then
anchor.CFrame = CFrame.new(anchor.Position, Vector3.new(
player.Character.Head.Position.X,
anchor.Position.Y,
player.Character.Head.Position.Z))
anchor.CFrame = anchor.CFrame * CFrame.Angles(0, math.pi * 2 * amountNum / amount, 0)
anchor.CFrame = anchor.CFrame * CFrame.new(0, 0, 3) -- Place it farther from the player
end
wait(.1)
if not reward.Stats:FindFirstChild("Prompt") or not reward.Stats.Prompt.Value then
anchor.Touched:Connect(function(part)
if part.Parent ~= nil and part.Parent.Name == recipient and part.Name == "HumanoidRootPart" and touched == false then
if Players:FindFirstChild(recipient) then
touched = giveItem(reward.Name, recipient)
if touched == true then
model:Destroy() -- Remove model after collected
sendInventoryUpdate(player)
else -- Inventory full
print('inventory full')
end
else
model:Destroy()
end
end
end)
else
reward.Prompt.Parent = anchor
anchor.Prompt.Triggered:Connect(function(player)