Remote event passed value turns nil on the client

This is inside my module script that i call on the server

for i,v in pairs(Skill2Folder:GetChildren()) do		
			if v.Name == "Hitbox" then
				local clone = v:Clone()
				clone.CFrame = char.HumanoidRootPart.CFrame
				clone.Parent = char
			else
				local clone = v:Clone()
				clone.Parent = char   
			end
		end
		
		local A1 = {}
		local A2 = {}
		
		for _,part in pairs(plr.Character:GetChildren()) do
			
			if part.Name == "StartPos" then
				print("Found Start")
				A1[plr] = part.Attatchment
				local a, b = getCorners(char.Hitbox)
				RandomSpawn(part, a, b)
				for _,part in pairs(plr.Character:GetChildren()) do
					if part.Name == "EndPos" then
						print("Found end")
						local a, b = getCorners(char.Hitbox) -- 
						RandomSpawn(part, a, b) -- ignore these two
						A2[plr] = part.Attatchment -- yes its mispelled but its the same as my attachment names
						
						print(A1[plr], A2[plr]) --prints Attachment, Attachment as it should
						
						Lightning:FireClient(plr, plr, A1[plr], A2[plr], 2)
					end
				end
			end
				
				
	
		end

and my local script

LightningRemote.OnClientEvent:Connect(function(plr, A1, A2, move)
	
	print(plr, A1, A2, move) -- prints my username, nil, nil, 2

I think you cant use instances in events, because it has limitations of memory. But you can use other way, for example: transfer properties.

oh i see well my code is not efficient at all so i dont mind completely rewriting (my game freezes every time I run this probably because I used a for loop inside of another for loop)

basically i want to fire the remote every time I find a pair of “Start Pos” and “End Pos” located inside the player’s character is there a way to do this?

I think you have to try this code:

for i, v in pairs(Skill2Folder:GetChildren()) do
	local clone = v:Clone()
	if v.Name == "Hitbox" then
		clone.CFrame = char.HumanoidRootPart.CFrame
	end
	clone.Parent = char
end

local A1 = {}
local A2 = {}

local attachmentPairs = {}

for _, part in pairs(plr.Character:GetChildren()) do
	if part.Name == "StartPos" then
		A1[plr] = part.Attachment
		attachmentPairs[plr] = attachmentPairs[plr] or {}
		attachmentPairs[plr].Start = part.Attachment

		local a, b = getCorners(char.Hitbox)
		RandomSpawn(part, a, b)
	elseif part.Name == "EndPos" then
		A2[plr] = part.Attachment
		attachmentPairs[plr] = attachmentPairs[plr] or {}
		attachmentPairs[plr].End = part.Attachment

		local a, b = getCorners(char.Hitbox)
		RandomSpawn(part, a, b)
	end
end

for player, attachments in pairs(attachmentPairs) do
	if attachments.Start and attachments.End then
		print(attachments.Start, attachments.End)
		Lightning:FireClient(plr, plr, attachments.Start, attachments.End, 2)
	end
end

yeah this is much better but Im still getting nil values on the client

Exactly, because I wasn’t going to change that. I don’t even have the code for the local script. But you need to create an attachment on a local script using properties sent from the server script

Thats odd because I was able to get this working with my first skill move, using the same method of sending the attachment only that time it was much simpler and I only had to fire it once. Im just going to continue investigating

I think you didn’t reach the memory limit and were able to send an attachment.