Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

0
?f your working on something Big ? dont suggest making it oppen source some exploiters might be in this Comunity gjlkv1 11 — 4y
0
Give us the script where you call that function. youtubemasterWOW 2741 — 4y
0
It's this one Clxud_D 9 — 4y
0
I edited my answer. LikeToScript 108 — 4y
0
gjlkv1 it's an AlvinBlox tutorial so thousands of people know the code already. DesertusX 435 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

0
I can't because after i will get the error Headless is not a valid menber of ServerStorage Clxud_D 9 — 4y
0
I defined it in DressHeadless function Clxud_D 9 — 4y
0
@Clxud_D define it outside that function because, other functions can't access it! LikeToScript 108 — 4y
0
I did @LikeToScript but it still don't work Clxud_D 9 — 4y
0
@Clxud_D, I'm sorry looks I don't know how to fix it. :( LikeToScript 108 — 4y
Ad

Answer this question