Help with "Valid Member"

Hello

I am trying to make a game similar to Murder Mystery and the weapons are randomized every game. I’m trying to clone folders that contain the scripts for the weapons to function and it’s working fine but once the second match starts the output comes out with this error:

Screenshot 2024-02-26 194140

I don’t really know what to do since I thought I fixed it with another post I saw but it didn’t.

The Variables

local repscripts = replicatedstorage:WaitForChild("Scripts")

local maniacscripts = repscripts:WaitForChild("Sword Function"):Clone()
local capturerscripts = repscripts:WaitForChild("Net Gun Function"):Clone()

The Pickup function whenever the “Sheriff” dies.

	local given = false
	pickup.Touched:connect(function(hit)
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		if humanoid and humanoid.Health > 0 then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			if player and player ~= bloxxer then
				local backpack = player:FindFirstChild("Backpack")
				if backpack and not given then
					given = true
					pickup:remove()
					local netgun = capturerweapons[math.random(1, #capturerweapons)]:clone()
					capturerscripts.Parent = netgun
					capturerscripts.NetGunScript.Enabled = true
					capturerscripts.NetGunLocalScript.Enabled = true
					netgun.Parent = backpack
					sheriff = player
				end
			end
		end
	end)

The clone variables of the first ones in the while loop

local clonemscripts = maniacscripts:Clone()
	local clonecscripts = capturerscripts:Clone()

Mostly where the problem is coming from:

if backpack then
					
					if player == bloxxer then
						event:FireClient(player, "Class", "Bloxxer")
						local knife = maniacweapons[math.random(1, #maniacweapons)]:Clone()
						clonemscripts.Parent = knife
						clonemscripts.Server.Enabled = true
						clonemscripts.Client.Enabled = true
						knife.Parent = backpack

					elseif player == sheriff then
						event:FireClient(player, "Class", "Sheriff")
						local netgun = capturerweapons[math.random(1, #capturerweapons)]:Clone()
						clonecscripts.Parent = netgun
						clonecscripts.NetGunScript.Enabled = true
						clonecscripts.NetGunLocalScript.Enabled = true
						netgun.Parent = backpack
					else
						event:FireClient(player, "Class", "Bystander")
					end
				end
			end

Any help would be appreciated, this post was rushed since I’m very tired and I’ve been working real hard on this, any help would be appreciated.

Right after this line, add the following code to debug:

print(capturerscripts:GetChildren())
print(capturerscripts:GetFullName())

Is the NetGunScript in there? Did you make a typo?

Here are the screenshots I captured:

Screenshot 2024-02-26 200254

This was from the line of code you provided.

Screenshot 2024-02-26 200406

The error still shows up when the second round starts, after the first one ended. And sorry if I wasn’t clear enough about the problem mostly showing up at this line:

Make sure log mode is turned off. This will let you see the inside of printed tables.

image

that didn’t use to be a thing, wasn’t it?
didn’t know that was a thing and I even knew about debug.traceback()

system removed my quote :what:

Sorry for the late response, but here is what I got when I turned off log mode.
Screenshot 2024-02-27 070055
The error is coming out on line 366 of the script which is this part that is marked.

1 Like