EDIT: So I believe that somewhere where i passed the CurrentCard variable through the fire function, i messed up. But im not sure where and how.

--Local Script
parent:WaitForChild("Confirm").MouseButton1Click:connect(function() -- Confirm button
	if Role == "Czar" then
		if PlayerPicking == false and confirmed == false then
			-- Code dis
		end
	else
		if PlayerPicking == true and confirmed == false and CurrentCard then
			local CardText = CurrentCard.Text
			print(CurrentCard) --Its not nil here yet
			game.ReplicatedStorage.SelectorConfirm:FireServer(Player,CurrentCard, CardText) -- possible point of mistake
			CurrentCard.Visible = false
			confirmed = true
		end
	end
--Server Script
PickedRoundCards = {}			
			for i, player in pairs(PlayingPlayers) do
				game.ReplicatedStorage.SelectorConfirm.OnServerEvent:connect(function(Player,CurrentCard, CardText)
					print(CurrentCard) -- its nil here??????
					table.insert(PickedRoundCards,CurrentCard)
					game.ReplicatedStorage.AddTurnedOverCard:FireAllClients(PickedRoundCards,CurrentCard)
				end)
			end

Extra code:

	local CardSelected = false
	local LastCard = nil
	
	for i, card in pairs(parent:WaitForChild("PersonalCards"):GetChildren()) do -- Card Click function
		card.MouseButton1Click:connect(function()
			CardSelected = true
			CurrentCard = card
			if LastCard ~= CurrentCard or nil then
				if LastCard ~= nil then
					LastCard:TweenSizeAndPosition(UDim2.new(LastCard.Size.X.Scale-.01,0,LastCard.Size.Y.Scale-.01,0),UDim2.new(LastCard.Position.X.Scale+.005,0,LastCard.Position.Y.Scale+.005,0),"InOut","Linear",.1,true)
				end
				card:TweenSizeAndPosition(UDim2.new(card.Size.X.Scale+.01,0,card.Size.Y.Scale+.01,0),UDim2.new(card.Position.X.Scale-.005,0,card.Position.Y.Scale-.005,0),"InOut","Linear",.1,true)
				LastCard = card
				print(CurrentCard)
			end
		end)
	end
game.ReplicatedStorage.AddTurnedOverCard.OnClientEvent:connect(function(PickedRoundCards)
	local CardOwner = CurrentCard.Parent.Parent.Parent.Parent -- Line where it errors
	local CardClone = CurrentCard:Clone()
	CardClone.Parent = script.Parent.Background
	CardClone.Name = CardOwner.Name
	CardClone.Size = UDim2.new(.102,0,.278,0)

6 comments

0

I do not see CurrentCard defined anywhere..

0

I didnt define it locally since i use it in the code later on

0

What do you mean? Just show us the entire code so we can figure it out, and fix the problem. Always include relevant code (not just where the error is situated).

0
  1. I mean i did not put local in it, because i do not want it to have a limited scope. When you remove local when you define a variable, it doesnt have a limited scope. 2.This is basically all the code that uses the CurrentCard variable.
0

If you define a local at the top of all of your code, it will be the equivalent of global, and it will also be defined properly, because global variables can confuse Lua sometimes. Where is the code that sets CurrentCard? That's where the problem is.

0

Well i went and defined CurrentCard at the top but its still showing an error that its nil on some clients