So i basically added a modification to a Free Model gun system, and i experienced a bug.
What is the issue ?
The issue is i experienced a bug which led to players shooting the gun while it’s unequipped
I’ll be providing some screenshots and a link to the vanilla version of the gun system.
Screenshots :
If you wait till the equip animation finished playing
If you unequipped the gun while the equip anim is playing
Code : [Gunscript_Local]
Tool.Equipped:connect(function(TempMouse)
if EquipAnim then EquipAnim:Play(nil,nil,Module.EquipAnimationSpeed) wait(0.5) Equipped = true end
UpdateGUI()
if Module.AmmoPerClip ~= math.huge then GUI.Parent = Player.PlayerGui end
TempMouse.Icon = "rbxassetid://"..Module.MouseIconID
if IdleAnim then IdleAnim:Play(nil,nil,Module.IdleAnimationSpeed) end
TempMouse.KeyDown:connect(function(Key)
if string.lower(Key) == "r" then
Reload()
elseif string.lower(Key) == "e" then
if not Reloading and AimDown == false and Module.SniperEnabled then
Workspace.CurrentCamera.FieldOfView = Module.FieldOfView
--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui") or Tool.ZoomGui:Clone()
GUI.Parent = game.Players.LocalPlayer.PlayerGui]]
GUI.Scope.Visible = true
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
script["Mouse Sensitivity"].Disabled = false
AimDown = true
Mouse.Icon="http://www.roblox.com/asset?id=187746799"
else
Workspace.CurrentCamera.FieldOfView = 70
--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
script["Mouse Sensitivity"].Disabled = true
AimDown = false
Mouse.Icon = "rbxassetid://"..Module.MouseIconID
end
end
end)
if Module.DualEnabled and not Workspace.FilteringEnabled then
Handle2.CanCollide = false
local LeftArm = Tool.Parent:FindFirstChild("Left Arm")
local RightArm = Tool.Parent:FindFirstChild("Right Arm")
if RightArm then
local Grip = RightArm:WaitForChild("RightGrip",0.01)
if Grip then
Grip2 = Grip:Clone()
Grip2.Name = "LeftGrip"
Grip2.Part0 = LeftArm
Grip2.Part1 = Handle2
--Grip2.C1 = Grip2.C1:inverse()
Grip2.Parent = LeftArm
end
end
end
end)
Tool.Unequipped:connect(function()
Equipped = false
GUI.Parent = script
if IdleAnim then IdleAnim:Stop() end
if AimDown then
Workspace.CurrentCamera.FieldOfView = 70
--[[local GUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("ZoomGui")
if GUI then GUI:Destroy() end]]
GUI.Scope.Visible = false
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
script["Mouse Sensitivity"].Disabled = true
AimDown = false
Mouse.Icon = "rbxassetid://"..Module.MouseIconID
end
if Module.DualEnabled and not Workspace.FilteringEnabled then
Handle2.CanCollide = true
if Grip2 then Grip2:Destroy() end
end
end)
Original gun system link
https://create.roblox.com/marketplace/asset/5975753299?viewFromStudio=true&keyword=R15%20Gun&searchId=2C040D4C-AA5B-4FBD-B1EE-3EBB0A16DA18
If you have any solution to this, let me know.
[I used my alt for this project since it holds some imported models]