I have a Script that lets you start with a certain camera position, doesn't let you move, and lets you move again when you press "play"
It gives an error message at line 20 saying that Character is not a valid member of Players How do I fix this?
The play button script:
script.Parent.MouseEnter:connect(function() for i = 1, 10 do script.parent.BorderSizePixel = script.Parent.BorderSizePixel +1 wait(0.01) end end) script.Parent.MouseLeave:connect(function() for i = 1, 10 do script.parent.BorderSizePixel = script.Parent.BorderSizePixel -1 wait(0.01) end end) script.Parent.MouseButton1Down:connect(function() script.parent.Visible = false script.Parent.Parent.Parent.StartLock.Disabled = true game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom local plr = script.Parent.Parent.Parent.Parent.Parent.Parent plr.Character.Humanoid.PlatformStand = false plr.Character.MoveTo(game.Workspace.Baseplate.Position) plr.Character.Torso.Anchored = false plr.Character.Humanoid.PlatformStand = false end) while true do if script.parent.BorderSizePixel > 11 then script.parent.BorderSizePixel = 11 end wait(0.1) end
The you can't move script:
local Player = game.Players.LocalPlayer local Cam = workspace.CurrentCamera local Target = Player.Character.Torso Cam.CameraType = Enum.CameraType.Scriptable Cam.CameraSubject = Player.Character.Torso while true do Cam.CoordinateFrame = CFrame.new(Target.Position) * CFrame.Angles(0,3.2,0) * CFrame.new(-2,0,5) wait(0.1) end
All of these scripts are located in playerGUI
And the play button script is located in a gui called "Startgui"
I really don't understand what's wrong, please help
FIrst of all it should be a local script cause you're doing gui related stuff.
The error it gives you is because you defined player wrong and have an extra parent which means you plr
variable was actually a variable for Players service I guess.
Since you should use a local script for this, you can just define a player like this:
local player = game.Players.LocalPlayer
and then also to define character make sure you don't just do player.Character
because since it's located inside of screen gui character might not load yet, therefore define your character like this:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait()
That should fix the error you had, however you might have to adjust some stuff if you were using a server script before.