I'm making a gun but it keeps coming back with "This mouse is no longer active"
Any help would be nice.
here is the script that the error is coming from.
local tool = script.Parent.Parent
local user
tool.Equipped:connect(function(mouse)
script.Parent.Parent.Loaded:Play()
user = tool.Parent
local player = game.Players:GetPlayerFromCharacter(user)
print("Equipped!")
function Fire()
local ray = Ray.new(tool.Hole.CFrame.p, (mouse.Hit.p - tool.Hole.CFrame.p).unit * 300)
local hit, position = game.Workspace:FindPartOnRay(ray, user)
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(100)
end
local distance = (position - tool.Handle.CFrame.p).magnitude
local rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("New Yeller")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.Material = Enum.Material.Plastic
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance - 6)
rayPart.CFrame = CFrame.new(position, tool.Hole.CFrame.p) * CFrame.new(0,0,-distance/2)
game.Debris:AddItem(rayPart, 1/30)
script.Parent.Parent.Ammo.Value = script.Parent.Parent.Ammo.Value - 1
wait(.1)
end
end)
game.ReplicatedStorage.Events.PPSH.OnServerEvent:Connect(function()
Fire()
end)
