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:
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.