Hi, i have a script that i push F to pick up a weapon and clone it to the backpack so i can equip it. I am currently using some gun models as a substitute for a while and when i push f on some weapons it will equip that weapon, but sometimes i pick up a gun and it wont equip the weapon but the weapon tool shows in game where it is positioned. (sorry if this isn't making sense). I have all my tools in the lightning space, and a part which looks exactly like the gun. where the tool is placed the tool will become visible when equipped. but the thing is if i use a click detector it works perfect. Any help is appreciated thanks :)
Model used - https://www.roblox.com/library/2273555208/PF-Gun-Pack-FE-SCRIPT-INCLUDED
My script(half from a youtube tutorial some from me):
local tools = {MP5 = true, Pistol = true, RoboRifle = true, UMP45 = true, SKS = true, GLOCK18 = true}
local radius = 10
local removeToolUponPickUp = true
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local running = false
local found
function getTools()
local found = {}
for i, c in pairs(game.Workspace.Weapons:GetChildren()) do
if tools[c.Name] then
table.insert(found, c)
end
end
return found
end
function walking(speed)
running = speed > 0 and true or false
while running and not found do
for i, tool in pairs(getTools()) do
local pos = tool:GetModelCFrame().p
if player:DistanceFromCharacter(pos) < radius then
found = true
local WSP = game.Workspace.CurrentCamera:WorldToScreenPoint(pos) -- The position of the WeaponsCFRAME
script.Parent.Visible = true
script.Parent.Position = UDim2.new(0,WSP.X,0,WSP.Y)
script.Parent.TextLabel.Text = "press F to pick up " ..tool.Name
found = tool
while true do
if player:DistanceFromCharacter(pos) > radius then
script.Parent.Visible = false
found = nil
break
end
wait(0.25)
end
end
end
wait(0.25)
end
end
mouse.KeyDown:connect(function(key)
if key:lower() == "f" and found then
local tool = game.Lighting[found.Name]:Clone()
tool.Parent = player.Backpack
script.Parent.Visible = false
if removeToolUponPickUp then
found:Destroy()
end
found = nil
end
end)
repeat
wait()
until player.Character
wait(0.5)
player.Character.Humanoid.Running:connect(walking)

2 comments
You want to store your weapons and other objects inside ServerStorage instead of Lighting (Will not solve your problem but wanted you to know..)
Thanks for the help still, will do that instead :)