My Script not working

My scripting is not working

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Camera = workspace.CurrentCamera

local Play = script.Parent.MenuFrame.Play

repeat wait()

Camera.CameraType = Enum.CameraType.Scriptable

until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = workspace.CameraPart.CFrame

Play.MouseButton1Click:Connect(function()

Camera.CameraType = Enum.CameraType.Scriptable

script.Parent.Parent:Destroy()

local Chapters = script.Parent.Parent.Chapters

local playerGui = player:WaitForChild("PlayerGui")

playerGui.Chapters.ChapterScreen.visible = true

end)

i tried to fix it but nothing worked

Are you trying to reset the camera back to the player after pressing the button? If so then in the event, you’re setting the CameraType to Scriptable whe nyou should be setting it to custom

Play.MouseButton1Click:Connect(function()

	Camera.CameraType = Enum.CameraType.Custom

	script.Parent.Parent:Destroy()

	local Chapters = script.Parent.Parent.Chapters

	local playerGui = player:WaitForChild("PlayerGui")

	playerGui.Chapters.ChapterScreen.visible = true

end)

No i meant to make a gui appear after pressing play

Then the issue is you didn’t capitalize visible,

playerGui.Chapters.ChapterScreen.visible = true

Should be

playerGui.Chapters.ChapterScreen.Visible = true

And you also didn’t capiatlize player, your playerGui variable line should be

local playerGui = Player:WaitForChild("PlayerGui")
1 Like

nope, it still didnt work
I dont know ill try another way

Are you getting any errors or is your output completely empty?

Where is your localscript located?

Edit: Wait I see something that could contribute to the problem,

script.Parent.Parent:Destroy()

local Chapters = script.Parent.Parent.Chapters

Here you’re destroying the 2nd parent of script, and t hen trying to get Chapters from it, which would be nil.Chapters

Looks like you wrote something wrong in your script. Did I find the error?

CursorPosition

Look at the line local playerGui = player:WaitForChild("PlayerGui")
There seems there is no variable called “player”. Capitalize the letter “P”

CursorPosition2

Me and Zed already mentioned that typo, but it wouldn’t have done anything since the error is happening earlier, also

@ZedDevX the issue is this line

script.Parent.Parent:Destroy()

You’re destroying the 2nd parent of the script, which also destroys the script and then afterwards trying to get the Chapters from it, which errors because script is nil now, put that line after

playerGui.Chapters.ChapterScreen.Visible = true
1 Like

its in the screengui

edit : if i remove the : Destroy

it breaks

Again, put

script.Parent.Parent:Destroy()

After

Chapters.Visible = true

You’re trying to get the parent of something on the next line for something that doesn’t exist anymore, that’s your issue

Also, why are you declaring the playerGui variable if the script is in StarterGui which gets cloned to PlayerGui anyways, and it’s never used so it’s kinda uneeded

1 Like