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

ServerScriptService.Game Logic.RoundModule:32: attempt to index nil with 'Name' ?

Asked by 3 years ago
local module = {}

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

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

function module.SelectChapter()
    local rand = Random.new()
    local chapters = game.ReplicatedStorage.Chapters:GetChildren() -- Table of all map models
    local chosenChapter = chapters[rand:NextInteger(1,#chapters)]

    return chosenChapter
end

function module.ChoosePiggy(players)

    local RandomObj = Random.new()

    local chosenPiggy = players[RandomObj:NextInteger(1,#players)]

    return chosenPiggy

end

function module.DressPiggy(Piggy)
    local character = game.ServerStorage.Piggy:Clone()
    character.Name = Piggy.Name

    Piggy.Character = character

    character.Parent = workspace
end

return module


and it says that character.Name = Piggy.Name is the problem

0
Tell us what you're passing through when you're calling the "DressPiggy" method. Or else we can't do anything. tantec 305 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Try use:

if value == nil then
    warn("Error")
    --script
end

or

 if value:FindFirstChild("Name") == nil then
    warn("Error")
    --script
end
Ad

Answer this question