I have an auto script but it doesn't work online because of the mouse but works on solo(studio). Any solutions? Here's my script.
local tool = script.Parent
local user
--when the tool is equipped
tool.Equipped:connect(function(mouse)
--store the character of the person using the tool
user = tool.Parent
--when the left mouse button is clicked
local autofire = false
tool.Activated:connect(function()
if not autofire then
autofire = true
while autofire do
wait(.15)
local fire = Instance.new("Sound")
fire.SoundId = "http://roblox.com/asset/?id=10209875"
fire.Volume = 0.5
fire.Parent = game.Workspace
fire:play()
--make and do a hit test along the ray
if mouse then
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)
local hit, position = game.Workspace:FindPartOnRay(ray, user)
--do damage to any humanoids hit
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(5)
end
--draw the ray
local distance = (position - tool.Handle.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright yellow")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
--add it to debris so it disappears after 0.1 second
game.Debris:AddItem(rayPart, 0.1)
end
end
end
end)
tool.Deactivated:connect(function()
autofire = false
end)
end)
Please help. The problem has something to do with the mouse that's it.

2 comments
Are you using FilteringEnabled? Also, I noticed at line 05, the connected anonymous function has no end. Is the activation event supposed to be nested inside the equipped event?
You haven't tried anything? You made a gun script and it didn't work, so you never tried fixing it? This is requesting