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

"PlayerScripts is not a valid member of Player"?

Asked by 5 years ago

I was making a class distribution function in a script in ServerScriptService . The function works fine on the tool distribution function (Using plr.Backpack). But it seems really stubborn on Local script distribution.

The local script is supposed to be cloned and parented into the player's PlayerScripts. Doesn't want to listen.

Code for the Local script clone, needs to be parented to PlayerScripts. (Output error problem)

game.ReplicatedStorage.Specials.OnServerEvent:Connect(function(plr,Loadout)
    for i,v in pairs(game.ReplicatedStorage.Classes.Specials:FindFirstChild(Loadout):GetChildren()) do
        for c,d in pairs(game.ServerStorage.Specials:GetChildren()) do
            if v.Name == d.Name then
                print(d.Name)
                local Clone = d:Clone()
                Clone.Parent = plr.PlayerScripts
            end
        end
    end
end)

The tool distribution script, in the same script as the local script being cloned.(Works)

game.ReplicatedStorage.Weapons.OnServerEvent:Connect(function(plr,Loadout)
    for i,v in pairs(game.ReplicatedStorage.Classes.Weapons:FindFirstChild(Loadout):GetChildren()) do
        for c,d in pairs(game.ServerStorage.Weapons:GetChildren()) do
            if v.Name == d.Name then
                print(d.Name)
                local Clone = d:Clone()
                Clone.Parent = plr.Backpack
            end
        end
    end
end)
0
Try doing plr:WaitForChild("PlayerScripts"). Aqu_ia 39 — 5y
0
The PlayerScripts object does not replicate to the server, it is only accessible and viewable on the client. FIamezR 15 — 5y
0
I've tried plr:WaitForChild('PlayerScripts'). But it says infinite wield rochel89 42 — 5y
0
Well, I've tried the script before. I once worked perfectly, the day after, I loaded it again and it gave me an error. rochel89 42 — 5y
View all comments (2 more)
0
is the first bit of code inside a localscript? Questofmagicfarts 55 — 5y
0
Both are in the same script, a server script. The second code is cloning a specific local script. rochel89 42 — 5y

Answer this question