'Attempt to index nil with Name'

I get this error if I run the function once I joined

local shadowCloneFolder = Instance.new(Folder)
shadowCloneFolder.Parent = workspace
shadowCloneFolder.Name = player.Name
1 Like
local shadowCloneFolder = Instance.new("Folder")

Gotta have it in quotation marks

Oh, also, you may not have defined player. Please provide the rest of your script

1 Like
function ShadowClone(player, numOfClones, despawnTime)
	if player == nil then return end
	local shadowCloneFolder = Instance.new("Folder")
	shadowCloneFolder.Parent = workspace
	shadowCloneFolder.Name = player.Name
end)

jutsuReceiver.OnServerEvent:Connect(function(player, handSigns, mouse)
	if handSigns == "X" and game.ServerStorage.JutsusLearned[player.Name]:FindFirstChild("Shadow Clone") then
		ShadowClone(player, numberOfClones, despawnTime)
	elseif handSigns == "GQThree" then
		print("Wolf Fang Avalanche Jutsu")
	elseif handSigns == "GThreeX" then
		print("Intelligent Hardwork Jutsu")
	elseif handSigns == "TwoThreeOneRY" then
		print("Summoning Jutsu")
	elseif handSigns == "XTwoTThreeZ" then
		print(mouse)
		SubstitutionJutsu(player, mouse)
	end
end)
1 Like

Hi!

Try putting print(player, shadowCloneFolder) before the shadowCloneFolder.Name = player.Name line, and send the full log of the error and the print.

1 Like

it only works if i wait for about 15 seconds

1 Like

Maybe “player” is not the player but something else? Can you tell me what the variables stand for?

1 Like

it’s a remote event, the first parameter is always the player

1 Like

You could try that:

game.Players.PlayerAdded:Connect(function(player)
local shadowCloneFolder = Instance.new(“Folder”)
shadowCloneFolder.Parent = workspace
shadowCloneFolder.Name = player.Name
end)

im only making an instance folder when using running the function

I wouldn’t be able to delete the folder if I made it with player added

you could if u make a function with a “return shadowCloneFolder” at the end of a function