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

[Solved] Why am I getting attempt to index nil with 'Parent'?

Asked by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

16:44:22.488 - ReplicatedStorage.broadcastController:04: attempt to index nil with 'Parent' 16:44:22.489 - Stack Begin
16:44:22.489 - Script 'ReplicatedStorage.broadcastController', Line 04 - function update
16:44:22.489 - Script 'Players.benbebop.PlayerScripts.connectedTo.RequestRadio.Scripts.sync', Line 12 16:44:22.490 - Stack End

Lines adjusted for given code

Local Module Script

function broadcast.update()
    game.ReplicatedStorage.clientPipeline.Broadcast.openBroadcast:InvokeServer(game.Players.LocalPlayer.PlayerScripts.connectedTo:GetChildren()[1].Id.Value)
    local connectedBroadcast = game.ReplicatedStorage.clientPipeline.InstanceTransfer[game.Players.LocalPlayer.Name]:GetChildren()
    connectedBroadcast[1].Parent = game.Players.LocalPlayer.PlayerScripts.connectedTo
    local GuiAssets = connectedBroadcast[1]["2dSpace"]:GetChildren()
    local Assets = connectedBroadcast[1]["3dSpace"]:GetChildren()
    local Scripts = connectedBroadcast[1]["Scripts"]:GetChildren()
    for i = 1,#GuiAssets do
        local x = GuiAssets[i]:Clone()
        x.Parent = game.Players.LocalPlayer.PlayerGui.Viewer.Window
    end
    for i = 1,#Assets do
        local x = Assets[i]:Clone()
        x.Parent = game.Players.LocalPlayer.PlayerGui.Viewer["3D"]
    end
    for i = 1,#Scripts do
        Scripts[i].Disabled = false
    end
end

Not much to say, I don't see where I'm going wrong here.

1 answer

Log in to vote
2
Answered by 4 years ago

broadcast[1], the first element of the table is nil, which is why it also errors at line 12, cuz you reference broadcast[1] again, as for why broadcast[1] is nil, I am not entirely sure, but I think it is most likely something to do with when you set the broadcast table, you set it like this: local broadcast = game.ReplicatedStorage.clientPipeline.InstanceTransfer[game.Players.LocalPlayer.Name]:GetChildren()

Firstly I question what you are doing looking for an instance with a player's name inside of replicated storage, I feel you should have told us what you put in there, secondly your doing this locally not necessarily a problem but I don't know what your trying to do so I am just saying you should think as if it needs to be done locally or on the server, thirdly your referencing player scripts which is an instance that only appears on the client parented by a player object, it is not there at all on the server.

That is the best I have, probably didn't fix your problem but at the same time, in my defense all you did was give a script and an error, please include more details, like at least tell us what your trying to do.

0
Also 2 broadcasts exist, the function and the variable you need to change the variable's name or the function's name to help as well FirezDevv 162 — 4y
0
The main purpose of this is to be able to get massive amounts of instance data, that I couldn't possibly use Instance.new() for, from one client to another. ReplicatedStorage is the only real way I could make it work. I assumed that it wouldn't need much context, since usually these things don't. Also this specific Module Script is only required by Local Scripts, so it works like a LocalScript. Benbebop 1049 — 4y
0
it is a module script so the function is technically called broadcast.update() and there is no chance that the function will be referenced beacause the script is defining the function so if you type the function name within the function it won't be anything special yumaking 78 — 4y
0
I fixed that already, still getting this error. I updated the post with my new script. The exact same code works fine in another part of the script which makes it all the more confusing. Benbebop 1049 — 4y
0
Ok so turns out it was unrelated to this script, because some random other script was making two instances when it should've made one. Thanks for the help none the less. Benbebop 1049 — 4y
Ad

Answer this question