So ive inserted a gun modeled from blender, put a handle part into the tool, and scripted with filtering enabled, yet when I try to equip the tool it simply does not show.
Note I also got a error:
Players.GoodkidMad.Backpack.m1911.Scripts.Main:25: attempt to index local 'mouse' (a nil value)
01 | -- Variables |
02 |
03 | local tool = script.Parent.Parent |
04 | local hole = tool.barrel |
05 | local handle = tool.Handle |
06 | local debounce = true |
07 | local config = tool.Config |
08 | local ammo = config.Ammo |
09 | local maxammo = config.MaxAmmo |
10 | local dmg = config.Damage |
11 | local allowtrace = config.AllowTracing |
12 | local clips = config.Clips |
13 | local range = config.Range |
14 | local plr = game:GetService( "Players" ).LocalPlayer |
15 | local cooldown = config.CoolDown |
Would greatly appreciate a response.
First things first - you have your button1down event which will create a new event on top of all the other times you equipped it. Your activated function will be fine instead since it fires every time a player clicks with the tool open.
I think your script is erroring saying mouse is nil because there are two mouse variables and the mouse variable that the script is referring to is the activated's mouse variable. Activated doesn't have a mouse parameter I think. Either way, you can get the mouse using Player:GetMouse() since this is a local script.
About your gun not showing, try without any scripts at all. Maybe it's not welded properly (if it's not a mesh in your handle this might be the case)
Turns out I needed to weld the guns parts, as far as the gun shooting (raycast) I had to change the debounce, to canShoot and change the true & false around. Also make sure when your using the (mouse) term you define!
local mouse = game.Players.LocalPlayer:GetMouse()
Full code look like this now:
01 | -- Variables |
02 |
03 | local tool = script.Parent.Parent |
04 | local hole = tool.barrel |
05 | local handle = tool.Handle |
06 | local canShoot = true |
07 | local config = tool.Config |
08 | local ammo = config.Ammo |
09 | local maxammo = config.MaxAmmo |
10 | local dmg = config.Damage |
11 | local allowtrace = config.AllowTracing |
12 | local clips = config.Clips |
13 | local range = config.Range |
14 | local plr = game:GetService( "Players" ).LocalPlayer |
15 | local cooldown = config.CoolDown |