function Gun.new()
return {
gunFire = function(self,typ,tool,damage,dbTime,hit)
tool.Equipped:Connect(function()
print("Equipped!")
end)
tool.Activated:Connect(function()
if not debounce then
debounce = true
Fire:FireServer("Semi",tool,damage,hit)
wait(dbTime)
debounce = false
end
end)
end
}
end
Local Script
local GunHandler = require(game.ReplicatedStorage.GunHandler)
local tool = script.Parent
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local var = GunHandler.new()
var:gunFire("Semi",tool,10,.5,mouse.Hit.Position)
You need to get the mouse position when the tool is activated, right now your passing the mouse position when the object is instantiated, hence it remains at a fixed location.
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
tool.Activated:Connect(function()
if not debounce then
debounce = true
Fire:FireServer("Semi",tool,damage,mouse.Hit.Position)
wait(dbTime)
debounce = false
end
end)