I keep getting this error with one of my games. The script is trying to find a value but it says its nil even tho it’s there
Script
game.ReplicatedStorage.ServerEvents.DealDaTraps:FireClient(x,game.ReplicatedStorage.TrapAmounts:FindFirstChild(x.EquippedTrap.Value).Value, true)
script 2
game.ReplicatedStorage.ServerEvents.DealDaTraps.OnClientEvent:Connect(function(amount, val)
if val == true then
script.Parent.Visible = true
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local trapCount = amount
script.Parent.Count.Text = trapCount
local function PlaceTrap()
game.Workspace.Bang:Play()
if script.Parent.Visible == true then
if trapCount >= 1 then
local mentor = 0
for i, v in pairs(game.Workspace.Map.Traps:GetChildren()) do
if (v.Position - plr.Character.HumanoidRootPart.Position).Magnitude <= 5 then
mentor = mentor + 1
end
end
if mentor >= 1 then
else
game.ReplicatedStorage.LocalEvents.PlaceDaTrap:FireServer()
trapCount = trapCount - 1
script.Parent.Count.Text = trapCount
end
end
end
end
script.Parent.Trap.MouseButton1Click:Connect(function()
PlaceTrap()
end)
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftControl then
PlaceTrap()
end
end)
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.LeftShift then
PlaceTrap()
end
end)
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.ButtonB then
PlaceTrap()
end
end)
else
script.Parent.Visible = false
end
end)
