Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

4 comments

0

What type of script is in starterplayer normal or local script

0

It is a local script, since its a camera script

0

ok I will take a look at it

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.

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.