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

Attempting to disable a script in StarterPlayerScripts, but returns error. Can anyone help?

Asked by 2 years ago

I am attempting to make a script that disables a script in the PlayerScripts folder but its coming back with an error I don't know how to fix.

script.Parent.Touched:Connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(part.Parent)
        game.Players[player.Name].PlayerScripts.CameraScript.enabled = false
    end
end)

That is the script. And when ever it runs when a player hits it it comes back with.

PlayerScripts is not a valid member of Player "Players.Xenaside"

(Xenaside is my username)

Anyone know how this can be resolved? I've been trying to fix this for a while now.

0
What type of script is in starterplayer normal or local script theking66hayday 841 — 2y
0
It is a local script, since its a camera script Student20986 0 — 2y
0
ok I will take a look at it theking66hayday 841 — 2y
1
That doesn't at all look like a local script, considering it's inside a part inside the workspace, where localscripts can't run unless they're inside a character. Use a RE to do some communication. joshthegamer456 93 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

If it's a local script, I would suggest putting it in a place where it can actually run (StarterCharacterScripts, StarterPlayerScripts, etc.). You also want an Remote Event in ReplicatedStorage. You need a server script inside of the part you are currently using, and make it communicate with your local script using the remote event.

Another suggestion: If you want the camera to stop moving, you could also use:

local camera = workspace.CurrentCamera -- Get the camera instance
camera.CameraType = Enum.CameraType.Scriptable -- Set the CameraType value to "Scriptable", stopping the player from moving it

I hope this helped at least a little bit!

Ad

Answer this question