Copy salient and essential scripts and models from Plane Building Roblox
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
local module = {}
|
||||
|
||||
local limit = 4
|
||||
|
||||
local bullet = require(_G.Modules.BulletModule)
|
||||
|
||||
function module.new(this,gun,context)
|
||||
this.barrel = _G.GetInstance(gun,"Barrel")
|
||||
this.binding = _G.GetInstance(gun,"Binding")
|
||||
this.rate = _G.GetValue(gun,"Rate",0.15)
|
||||
this.last = tick()
|
||||
end
|
||||
|
||||
module.run = _G.Protect(function(this,gun,context)
|
||||
if (this.control or context.controls[this.binding.Value] or 0) < 0.5 then return true end
|
||||
if tick() - this.last < this.rate then return true end
|
||||
-- Fire
|
||||
bullet.fire(this.barrel)
|
||||
this.last = tick()
|
||||
this.barrel:ApplyImpulse(this.barrel.CFrame.RightVector * -500)
|
||||
return true
|
||||
end)
|
||||
|
||||
module.fire_rate = 0.05
|
||||
|
||||
module.messages = {
|
||||
control = function(this,gun,context,value)
|
||||
this.control = value
|
||||
end,
|
||||
}
|
||||
|
||||
module.manifest = {
|
||||
"Gun",
|
||||
"Cannon"
|
||||
}
|
||||
|
||||
return module
|
||||
Reference in New Issue
Block a user