"Configs is not a valid member of Tool" is a problem i have that I can't fix. I don't know what it means nor to fix. From what I know, Configs is my folder that contains NumberValues and Configs is not a valid member of Tool?
My problem occurs when I try to host a 2 player server in Roblox Studio. Also is there any more improvements I can do in my script?
The problem is at line 5.
--Variables
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
local Config = tool.Configs
local Ammo = Config.Ammo
local maxAmmo = Config.maxAmmo
local reloadTime = Config.reloadTime
local damage = Config.damage
local rTime = Config.rTime
local color = Config.Color.Value
local debounce = false
local isReloading = false
--Variables of Parts
local beam1 = tool.Beam1
local beam2 = tool.Beam2
local beam3 = tool.Beam3
local beam4 = tool.Beam4
local beam5 = tool.Beam5
local beam6 = tool.Beam6
local beam7 = tool.Beam7
local Barrel = tool.Barrel
local Handle = tool.Handle
local FrontSight = tool.FrontSight
local LeftSight = tool.LeftSight
local RightSight = tool.RightSight
local Slide = tool.Slide
local Table = tool.Table
local Muzzle = tool.Muzzle
--Sounds
local fireSound = tool.Audio.FireSound
local equipSound = tool.Audio.EquipSound
--TO-DO list
--fixing firespamming -Fixed
--fix the reload sequence -Fixed
--Color of the beam should be represented by team Color or by a custom color -Fixed
--Simplyify the scripts, better performance and easier changing of variables
--Sounds when Charging and firing
tool.Equipped:connect(function(mouse)
--Making part's CanCollide to false
beam1.CanCollide = false
beam2.CanCollide = false
beam3.CanCollide = false
beam4.CanCollide = false
beam5.CanCollide = false
beam6.CanCollide = false
beam7.CanCollide = false
Barrel.CanCollide = false
Handle.CanCollide = false
FrontSight.CanCollide = false
LeftSight.CanCollide = false
RightSight.CanCollide = false
Slide.CanCollide = false
Table.CanCollide = false
Muzzle.CanCollide = false
--Changing of Part Colors
beam1.BrickColor = color
beam2.BrickColor = color
beam3.BrickColor = color
beam4.BrickColor = color
beam5.BrickColor = color
beam6.BrickColor = color
beam7.BrickColor = color
--Playing equipSound
equipSound:Play()
--tool is equipped
print("Tool Equipped!")
mouse.Button1Down:connect(function()
if not isReloading then
if Ammo.Value > 0 then
--Playing fireSound
fireSound:play()
--Drawing the ray
local ray = Ray.new(Muzzle.CFrame.p, (mouse.Hit.p - Muzzle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
--Drawing the beam
local beam = Instance.new("Part", workspace)
beam.BrickColor = color
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.BackSurface = "SmoothNoOutlines"
beam.BottomSurface = "SmoothNoOutlines"
beam.FrontSurface = "SmoothNoOutlines"
beam.LeftSurface = "SmoothNoOutlines"
beam.RightSurface = "SmoothNoOutlines"
beam.TopSurface = "SmoothNoOutlines"
beam.Transparency = .15
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
--Distance
local distance = (Muzzle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(Muzzle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
--Removing the beam
game:GetService("Debris"):AddItem(beam, 1 / 20)
--Checking if it's player
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(damage)
end
end
--Decreasing the ammo value by one when fired
Ammo.Value = Ammo.Value - 1
if Ammo.Value == 7 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Neon"
beam7.Material = "Neon"
elseif Ammo.Value == 6 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Neon"
beam7.Material = "Plastic"
elseif Ammo.Value == 5 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
elseif Ammo.Value == 4 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
elseif Ammo.Value == 3 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
elseif Ammo.Value == 2 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Plastic"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
elseif Ammo.Value == 1 then
beam1.Material = "Neon"
beam2.Material = "Plastic"
beam3.Material = "Plastic"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
elseif Ammo.Value == 0 then
beam1.Material = "Plastic"
beam2.Material = "Plastic"
beam3.Material = "Plastic"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
end
print("You Have " ..Ammo.Value.. " Left!")
else
--Out of Ammo
end
end
--Reloading Sequence
mouse.KeyDown:connect(function(key)
key:lower()
if key == "r" then
if not isReloading then
isReloading = true
print("Energy Pistol is reloading")
for i = 0, 6, 1 do
Ammo.Value = Ammo.Value + 1
wait(.5)
if Ammo.Value == 1 then
beam1.Material = "Neon"
beam2.Material = "Plastic"
beam3.Material = "Plastic"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 2 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Plastic"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 3 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Plastic"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 4 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Plastic"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 5 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Plastic"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 6 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Neon"
beam7.Material = "Plastic"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 7 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Neon"
beam7.Material = "Neon"
print("You have reloaded " ..Ammo.Value.. " beams!")
elseif Ammo.Value == 0 then
beam1.Material = "Neon"
beam2.Material = "Neon"
beam3.Material = "Neon"
beam4.Material = "Neon"
beam5.Material = "Neon"
beam6.Material = "Neon"
beam7.Material = "Neon"
print("You have reloaded " ..Ammo.Value.. " beams!")
end
end
isReloading = false
print("Energy Pistol is ready!")
end
end
end)
end)
end)

1 comment
you could use tool:WaitForChild("Configs")