I am restoring old models, and i am trying to fix a old raycast gun’s aim. Im having a problem with the automatic guns, because they only shoot at click pos, not the mouse pos. When shooting a auto rifle, you hold down the left mouse button, and it still only counts as 1 to 2 clicks. Please help, because ive tried each FE enabled method and code.
THIS MODEL IS OPEN SOURCE, DONT WORRY, IM NOT LEAKING PERSONAL WORK. gun - Roblox - model to inspect in.
You can constantly check for the mouse position when MouseButton1Down and break the loop when MouseButton1Up so while you are holding, it will always check for the current mouse position.
Hi on a new topic.
As I said before, putting print statements helps you see where the problem is. I looked at the code in the model and if we do this:
local function onActivationReceive(sendingPlayer,down,target)
print("FIRE", target) --works OK
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
if humanoid then
print("Hum", humanoid)
local tool= char:FindFirstChildWhichIsA("Tool")
print("Tool", tool)
if tool then
We see guns fires to the server with a CFrame, but no Humanoid is found. That is because the character should be defined on an Equipped event. Or you can do:
local humanoid = tool.Parent:FindFirstChildWhichIsA("Humanoid")
...
local tool =tool.Parent:FindFirstChildWhichIsA("Tool")
Then we get all the variables defined correctly, but the best way is to define these on the Equipped event really
function onEquip()
local char= script.parent
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
local tool= char:FindFirstChildWhichIsA("Tool")
end
self.Equipped:connect(onEquip)