I wanna make a custom gun system for my place but function in ModuleScript doesnt executing but module works perfectly, require a module is works but function isnt working.I’m trying use command line and function works!
How is that working?
LocalScript of Tool:
local gunModule = require(game.ReplicatedStorage.modules.GunModule)
local hasVm = false
local vm = nil
game:GetService("RunService").RenderStepped:Connect(function(dlt)
if hasVm then
vm:FindFirstChild("CameraBone").CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0.8,-0.6,-0.5)-- * CFrame.Angles(0,math.rad(90),0)
end
end)
script.Parent.Equipped:Connect(function()
vm, hasVm = gunModule.changeViewmodel(game.ReplicatedStorage.vms.ak12)
end)
script.Parent.Unequipped:Connect(function()
vm, hasVm = gunModule.changeViewmodel()
end)
ModuleScript:
local module = {}
function module.changeViewmodel(vm:Model):(Model,boolean)
local hasViewmodel = false
if workspace.CurrentCamera:FindFirstChild("vm") ~= nil then hasViewmodel = true else hasViewmodel = false end
if hasViewmodel then
workspace.CurrentCamera:FindFirstChild("vm"):Remove()
hasViewmodel = false
end
if vm ~= nil then
local clone = vm:Clone()
clone.Name = "vm"
clone.Parent = workspace.CurrentCamera
hasViewmodel = true
return clone,hasViewmodel
end
return nil,hasViewmodel
end
return module
Please help, im really dont know how this works?
(EDIT: no error in console btw)