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

Thing with GUI and Camera manipulation script doesn't work please help?

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

1 answer

✓ Accepted answer

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.

4 comments

0

well then fix your plr variable like I told you

0

Now it gives the error expected '.' not ':' calling member function MoveTo

0

that's because you used character.MoveTo() instead of character:MoveTo()

0

Thanks man, you're my hero! :)

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