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

Why am i receiving an error stating that "PlayerScripts is not a valid member of player"?

Asked by 6 years ago
Edited 6 years ago

Hello i'm trying to disable the "ControlScript" in PlayerScripts which is a folder in the player (similar to 'PlayerGui') But whenever i try to access the 'PlayerScripts' folder i receive the error saying the folder is not a valid member of player...

I've tried using ":WaitForChild", "Repeat wait()" and even for loops but all 3 of those ways are not working and i keep getting the same result. It is very weird and i remember having this problem a while back with the PlayerGui folder but gave up on that project because of that error.

Here is the script as of current (Server Script):

local path = require(game.ServerScriptService.Modules:FindFirstChild("NoirPhoenix's Pathfinding"))
local Target = workspace.Portal:WaitForChild("Target")


game.ReplicatedStorage.Events.Challenge.OnServerEvent:Connect(function(plr,ePlr)
        print(plr)
        print(ePlr)

        plr.PlayerScripts:WaitForChild("ControlScript").Disabled = true
        ePlr.PlayerScripts:WaitForChild("ControlScript").Disabled = true        




        path.new(plr.Character,Target)
        path.new(ePlr.Character,Target)

end)
1
Bcuz you cant get PlayerScripts from server script. You need to fire client from server, and on client get it HaveASip 494 — 6y
1
i think you could just copy the control script and paste it inside starterplayer in one of the folders and disable it User#23365 30 — 6y
1
put it in StarterPlayerScripts i tested it and it works lol User#23365 30 — 6y
1
No dude, he cant disable it with script. He need to fire the client from server and on client localscript disable it HaveASip 494 — 6y
View all comments (4 more)
0
I only want to disable it after both players agree to dual. NoirPhoenix 148 — 6y
1
i suggest just making the humanoid's WalkSpeed and JumpPower to 0 if you dont want the character to move User#23365 30 — 6y
0
The idea was to disable the clients movement but my pathfind script to move the plr over to a targetted area. NoirPhoenix 148 — 6y
1
k User#23365 30 — 6y

1 answer

Log in to vote
1
Answered by
HaveASip 494 Moderation Voter
6 years ago

Bcuz you cant get PlayerScripts from server script. You need to fire client from server, and on client get it

----[[ Server script ]]-----
local path = require(game.ServerScriptService.Modules:FindFirstChild("NoirPhoenix's Pathfinding"))
local Target = workspace.Portal:WaitForChild("Target")
local event = game:GetService("ReplicatedStorage").Events:WaitForChild("Challenge")


event.OnServerEvent:Connect(function(plr,ePlr)
        print(plr)
        print(ePlr)


        event:FireClient(plr, true)
        event:FireClient(ePlr, true)



        path.new(plr.Character,Target)
        path.new(ePlr.Character,Target)

end)


----[[ Client Script "LocalScript" ]]-----
local player = game:GetService("Players").LocalPlayer
local event = game:GetService("ReplicatedStorage").Events:WaitForChild("Challenge")
local controlScript = player.PlayerScripts:WaitForChild("ControlScript")


event.OnClientEvent:Connect(function(Variable)
    controlScript.Disabled = Variable
end)
0
Thankyou. :) NoirPhoenix 148 — 6y
0
You are welcome. HaveASip 494 — 6y
Ad

Answer this question