Script not working

  1. What do you want to achieve? Keep it simple and clear!

I want to unenable a gui in the starterplayerscripts when a player’s character is added.

  1. What is the issue? Include screenshots / videos if possible!

When I access the playergui, I can’t enable the gui.

Local script in StarterPlayerScripts:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Events = ReplicatedStorage.Events

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid

local playerGui = player.PlayerGui

player.CharacterAdded:Connect(function()
        playerGui.StartGui.Enabled = true
	camera.CameraType = "Scriptable"
	camera.CFrame = workspace.StartCamera.CFrame
	Events.Initiate:FireServer("Start")
end)

Local script in button in start screen GUI:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Events = ReplicatedStorage.Events

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local camera = workspace.CurrentCamera


script.Parent.MouseButton1Up:Connect(function()
	script.Parent.Parent.Parent.Enabled = false
	camera.CameraType = "Scriptable"
	camera.CFrame = workspace:WaitForChild("Arcade"):WaitForChild("ArcadeCamera").CFrame
end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Using a bindable but I wanted to find out about this.

On the line with a weird space is the issue. That’s where enabling doesn’t work.

script.Parent.MouseButton1Up:Connect(function()

should be MouseButton1Down. MouseButton1Up only works if you have let go of the button after holding it.

But I still clicked it and the UI changed my camera. My issue also isn’t in the button script, it starts in the client script in starterplayerscripts.

Could you please put a print statement one every 2 lines? Different text ofcourse, with it we can debunk where the script is error.

Try:
local playerGui = player:WaitForChild("PlayerGui")
(The client might not have had time to register the PlayerGui)

Also, try changing the line after it to:
camera.CameraType = Enum.CameraType.Scriptable

1 Like

I see my issue, I put my code in the character added event in the starter player script, but I don’t know why that broke it.