so i am making a gun script while i test if it works i come across an error i don't get since i myself made a mouse variable and the function itself is ':connect(function(mouse)'
i do not have much time to reply but all help is appreciated
THE ERROR IS AT LINE 18
script:
ammo = script.Parent.Ammo
clipsize = script.Parent.ClipSize
insideclip = script.Parent.StoredAmmo
shotfrom = script.Parent.Main
debounce = true
dmg = 16
range = 1000
allowtracing = true
player = game.Players.LocalPlayer
mouse = player:getMouse()
script.Parent.Equipped:connect(function()
local char = script.Parent.Parent
script.Parent.Activated:connect(function(mouse)
if debounce then
debounce = false
local ray = Ray.new(shotfrom.CFrame.p (mouse.hit.p - shotfrom.CFrame.p) * range.Value)
local hit, position = workspace:FindPartOnRay(ray, char, false, true)
if allowtracing.Value == true then
local trace = Instance.new('Part', workspace)
trace.Material = Enum.Material.Neon
trace.Color = Color3.new(255,255,0)
trace.CanCollide = false
trace.Anchored = true
trace.Transparency = 0.3
local distance = (shotfrom.CFrame.p - position).magnitude
trace.Size = Vector3.new(0.2, 0.2, distance)
trace.CFrame = CFrame.new(shotfrom.CFrame.p, position) * CFrame.new(0,0,-distance/2)
-----
game:GetService('Debris'):AddItem(trace, 0.1)
end
--- hit detection
if hit then
local humanoid = hit.Parent:FindFirstChild('Humanoid')
if humanoid then
if hit.Name == 'Head' then
humanoid:TakeDamage(dmg.Value * 2)
else
humanoid:TakeDamage(dmg.Value)
end
end
end
wait(0.01)
debounce = true
end
end)
end)

1 comment
http://wiki.roblox.com/index.php?title=API:Class/Tool/Activated
mouseisn't a parameter of Tool.Activated event listeners