I decided to change pickup mechanic form Prompt to Raycasting so It could prevent people from picking weapons up on death
Everything was going alright at first
Until when I pick up then turn my camera away from the weapon, It does not catch up the weapon data properly, and not destroy the weapon as well
My pickup code (Client side):
function confirmWeapon(weapon)
if lastWeapon ~= weapon then
lastWeapon = weapon
if lastWeapon ~= nil then
CAS:BindAction("PickupWeapon", function(actionName, inputState)
if inputState == Enum.UserInputState.Begin then
gunPickup(lastWeapon,
lastWeapon:GetAttribute('CurrentAmmo'),
lastWeapon:GetAttribute('AmmoStorage'),
lastWeapon:GetAttribute('GunValue')
)
gunDestroy:FireServer(lastWeapon)
end
end, true, Enum.KeyCode.E)
else
CAS:UnbindAction("PickupWeapon")
end
end
end
Destroy weapon (Server side):
local RS = game:GetService('ReplicatedStorage')
local event = RS.Events:WaitForChild('GunDestroy')
event.OnServerEvent:Connect(function(player, weapon)
weapon:Destroy()
end)
(Do not worry about defining variables, I did it properly in my game)
I tried to shoot ray after presseing E key, but nothing changed, but I cannot change back to ProximityPrompt cuz there is currently no way to disable the entire player’s keyboard (I tried from many posts and still failed)