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 6 years ago
Edited 6 years ago

Ok so heres my problem. I want to make basically a startup script that replaces the health, sound, animation, etc scripts. I also wanted to disable the scripts from PlayerScripts in game.Players.Player1 but when I try to disable it, it shows up as nil. Heres my script

01--setup scrip v1.0
02 
03local Players = game:GetService("Players")
04 
05local function onCharacterAdded(character)
06    print(character.Name .. " has joined the rumble")
07    local playerc=game.Players:GetPlayerFromCharacter(character)
08 
09    character.Animate:remove()
10    character.Sound:remove()
11    character.Health:remove()
12 
13    playerc.PlayerScript.ControlScript.Disabled=true
14    playerc.PlayerScript.CameraScript.Disabled=true
15    --playerc.StarterPlayerScripts.ControlScript.Disabled=true
View all 27 lines...

playerc is the variable I'm having problems with. I even did a few different tests like waiting for 10-20 seconds(possibly a load error) but nothing. At some point I tried this

1x=playerc:GetChildren()
2for i=1, #x do
3    print(x[i].Name)
4end

And found that the only objects it registered were Backpack, PlayerGui, and StarterGear. If anyone can help me with found PlayerScripts that would be great.

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
6 years ago
Edited 6 years ago

As outlined in the api reference for PlayerScripts, the PlayerScripts container is not visible to the server. In order to ameliorate this problem, simply connect an event listener to the CharacterAdded event from a local script, and perform the necessary action there.

Note: Use Destroy() not Remove()! Remove() is deprecated.
Ad

Answer this question