45 lines
1.0 KiB
Lua
45 lines
1.0 KiB
Lua
local module = {}
|
|
|
|
function module.new(this,disconnector,context)
|
|
this.grip = _G.GetInstance(disconnector,"Grip")
|
|
this.binding = _G.GetInstance(disconnector,"Binding")
|
|
return this
|
|
end
|
|
|
|
module.run = _G.Protect(function(this,disconnector,context)
|
|
if this.control or 0 < 0.5 and context.queue(this,module.name,0.4) then
|
|
context.replicate(this,disconnector,module)
|
|
elseif context.controls[this.binding.Value] or 0 < 0.5 then
|
|
context.replicate(this,disconnector,module)
|
|
end
|
|
return true
|
|
end)
|
|
|
|
module.replication_delta = 0.25
|
|
function module.replicate(this,disconnector,context)
|
|
if _G.IsClient then return end
|
|
for _,weld in pairs(this.grip:GetJoints()) do
|
|
if
|
|
weld:IsA("WeldConstraint") and
|
|
weld.Name == "BuiltWeldConstraint" and
|
|
weld.Parent
|
|
then
|
|
weld:Destroy()
|
|
end
|
|
end
|
|
this.grip.Transparency = 1
|
|
task.delay(0.3,function() this.grip.Transparency = 0 end)
|
|
end
|
|
|
|
module.messages = {
|
|
control = function(this,disconnector,context,value)
|
|
this.control = tonumber(value)
|
|
end,
|
|
}
|
|
|
|
module.manifest = {
|
|
"Disconnector"
|
|
}
|
|
|
|
return module
|