Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am still making a piggy game and i changed the name but what is this new error ?

It say : 16:49:04.094 - ServerScriptService.Game Logic.RoundModule:34: attempt to index nil with 'Name'

And my script :

local module = {}

local status = game.ReplicatedStorage:WaitForChild("Status")

function module.Intermission(length)
	for i = length,0,-1 do
		status.Value = "Nex round starts in "..i.." seconds"
		wait(1)
	end
end

function module.SelectChapter()
	local rand = Random.new()
	local chapters = game.ReplicatedStorage.Chapters:GetChildren()
	local chosenChapter = chapters[rand:NextInteger(1,#chapters)]
	
	return chosenChapter
end

function module.ChooseHeadless(players)
	
	local RandomObj = Random.new()
	
	local players = game.Players:GetPlayers()
	
	local chosenHeadless = players[RandomObj:NextInteger(1,#players)]
	
	return chosenHeadless
	
end

function module.DressHeadless(headless)
	local character = game.ServerStorage.Headless:Clone()
	character.Name = headless.Name
	headless.Character = character
	character.Parent = workspace
end

function module.TeleportHeadless(player)
	if player.Character then
		
		player.Character.Humanoid.WalkSpeed = 14
		
		local bat = game.ServerStorage.Tools.PiggyBat
		bat.Parent = player.Character
		
		if player.Character:FindFirstChild("HumanoidRootPart") then
			player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.PiggyWaitingSpawn.CFrame + Vector3.new(0,5,0)
		end
		
	end
end

function module.TeleportPlayers(players, mapSpawns)
	
	
	
	for i, player in pairs(players) do
		if player.Character then
			local character = player.Character
			
			if character:FindFirstChild("HumanoidRootPart") then
				
				player.Character.Humanoid.WalkSpeed = 16
				
				local rand = Random.new()
				player.Character.HumanoidRootPart.CFrame = mapSpawns[rand:NextInteger(1,#mapSpawns)].CFrame + Vector3.new(0,10,0)
				
			end
		end
	end
	
end

return module

5 comments

0

?f your working on something Big ? dont suggest making it oppen source some exploiters might be in this Comunity

0

Give us the script where you call that function.

0

It's this one

0

I edited my answer.

0

gjlkv1 it's an AlvinBlox tutorial so thousands of people know the code already.

1 answer

Hi, it seems like you forgot to define 'Headless' that's why it say's that it's NIL.

5 comments

0

I can't because after i will get the error Headless is not a valid menber of ServerStorage

0

I defined it in DressHeadless function

0

@Clxud_D define it outside that function because, other functions can't access it!

0

I did @LikeToScript but it still don't work

0

@Clxud_D, I'm sorry looks I don't know how to fix it. :(

This discussion is preserved as it was. New answers, comments, and votes are closed.