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
Edited 5 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

--setup scrip v1.0

local Players = game:GetService("Players")

local function onCharacterAdded(character)
    print(character.Name .. " has joined the rumble")
    local playerc=game.Players:GetPlayerFromCharacter(character)

    character.Animate:remove()
    character.Sound:remove()
    character.Health:remove()

    playerc.PlayerScript.ControlScript.Disabled=true
    playerc.PlayerScript.CameraScript.Disabled=true
    --playerc.StarterPlayerScripts.ControlScript.Disabled=true
end

local function onCharacterRemoving(character)
    print(character.Name .. " has left the rumble")
end

local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
    --player.CharacterRemoving:Connect(onCharacterRemoving) --I'll reimplement this after main functions are done.
end

Players.PlayerAdded:Connect(onPlayerAdded)

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

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

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