"PlayerGui is not a valid member of player" error

So I can’t set my resetbuttoncallback to false, even through a localscript…
image

game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):SetCore("ResetButtonCallback",false)```

Try putting it in starterplayerscripts and change it to:

wait(2)
game:GetService("StarterGui"):SetCore("ResetButtonCallback", false)

The Roblox core scripts might take a little longer to load in than PlayerGui. To overcome this, I just used this code:

local StarterGui = game:WaitForChild(“StarterGui”)

local Success,Error = pcall(function()
StarterGui:SetCore(“ResetButtonCallback”, false)
end)

if Error then
while wait(0.1) do
local Success2,Error2 = pcall(function()
StarterGui:SetCore(“ResetButtonCallback”, false)
end)
if Success2 then
break
end
end
This will keep playing until the script successfully sets the ResetButtonCallback to false.

1 Like

Add 1 more end after the code word “break”.

Ok this worked, but now how would I change this for only a specific player? (not localplayer but another player)

Just add this to the top:

local localPlayer = game.Players.LocalPlayer

if localPlayer.UserId == Target Players User Id then
Put the code that started with local StarterGui = game:WaitForChild(“StarterGui”) in here.
end

Oh, sorry for not clarifying. I want to have the victim from this script have reset disabled.

-- Arrest System

-- Services
local PlayerService = game:GetService('Players')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local TeamService = game:GetService('Teams')
local PhysicService = game:GetService('PhysicsService')

-- Refrences
local Remotes = ReplicatedStorage.Remotes
local CuffRemote = Remotes.CuffEvent
local PlayerGroup = PhysicService:CreateCollisionGroup('PlayerGroup')
local PartGroup = PhysicService:CreateCollisionGroup('PartGroup')
local ReleaseGui = script.Parent.ReleaseGui

--PhysicService:CollisionGroupSetCollidable('PartGroup', 'PlayerGroup', false)

-- functions

local function OnCuff(Officer, Victim)
	-- Make sure they 'exist' and haven't left the game yet.
	if Officer and Victim then
		-- Make sure neither of them are dead.
		if Officer.Character.Humanoid.Health > 0 and Victim.Character.Humanoid.Health > 0 then
			-- Make sure that the player hasn't been cuffed by another officer
			if Victim:FindFirstChild('Cuffed') then
				return warn('Player cuffed by another officer')
			end

			if (Victim.Character.Head.Position - Officer.Character.Head.Position).Magnitude > 15 then
				return warn('Too far away!')
			end

			-- Prevent any other officers cuffing the victim
			local CuffedValue = Instance.new('IntValue')
			CuffedValue.Name = 'Cuffed'
			CuffedValue.Value = 1
			CuffedValue.Parent = Victim

			-- Play cuffed animation
			local CurrentAnimations = Victim.Character.Humanoid:GetPlayingAnimationTracks()
			-- stop any current animations (such as walking)
			for i, track in pairs (CurrentAnimations) do
				track:Stop()
			end

			Victim.Character.Humanoid.WalkSpeed = 0
			Victim.Character.Humanoid.JumpPower = 0
            Victim.Character.Humanoid.PlatformStand = true
			
			local CuffAnimation = Instance.new('Animation')
			CuffAnimation.AnimationId = 'rbxassetid://8722758589'
			CuffAnimation.Parent = Victim.Character

			local OfficerAnimation = Instance.new('Animation')
			OfficerAnimation.AnimationId = 'rbxassetid://8722767340'
			OfficerAnimation.Parent = Officer.Character

			local LoadedOfficer = Officer.Character.Humanoid:LoadAnimation(OfficerAnimation)
			LoadedOfficer:Play()
            
            local LoadedCuff = Victim.Character.Humanoid:LoadAnimation(CuffAnimation)
            LoadedCuff:Play()
            
			-- Weld the criminal to the Officer's hand so they can't move
            
			for _, Part in ipairs(Victim.Character:GetDescendants()) do
				if Part:IsA('BasePart') then
					Part.Massless = true
				end
            end

            Victim.Character.HumanoidRootPart.CFrame = Officer.Character:WaitForChild("HumanoidRootPart").CFrame * CFrame.new(0,.6,-2.5)  
            
            local Weld = Instance.new('WeldConstraint')
            Weld.Name = 'CriminalWeld'
            if Officer.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
                Weld.Part0 = Officer.Character.RightHand
                Weld.Part1 = Victim.Character.HumanoidRootPart
                Weld.Parent = Officer.Character
            elseif Officer.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
                Weld.Part0 = Officer.Character["Right Arm"]
                Weld.Part1 = Victim.Character.HumanoidRootPart
                Weld.Parent = Officer.Character
            end
			
			--Victim:WaitForChild("PlayerGui"):SetCoreGuiEnabled("ResetButtonCallback",false)
			
			ReleaseGui.Parent = Officer.PlayerGui
			ReleaseGui.Enabled = true
			
            Remotes.ReleaseEvent.OnServerEvent:Connect(function()
                Officer.Character:FindFirstChild("CriminalWeld"):Destroy()
                Victim.Character.Humanoid.PlatformStand = false
                Victim.Character.Humanoid.WalkSpeed = 16
                Victim.Character.Humanoid.JumpPower = 50
                LoadedCuff:Stop()
                LoadedOfficer:Stop()
				Victim:FindFirstChild('Cuffed'):Destroy()
				ReleaseGui.Enabled = false
				--Victim:WaitForChild("PlayerGui"):SetCoreGuiEnabled("ResetButtonCallback",false)
			end)
			
			if Victim.Character.Humanoid.Health <= 0 and Victim:FindFirstChild('Cuffed') then
				Officer.Character:FindFirstChild("CriminalWeld"):Destroy()
				Victim:Kick("You have been kicked for suspected respawn exploits while in handcuffs.")
			end
		end
    end
end

CuffRemote.OnServerEvent:Connect(OnCuff)```

Just use a remote event and fire it to the victim’s client only.

Alr, thx
3O characters limit bypass

I have fired the client, but only the officer’s reset is locked, not the victim’s.

Remotes.AntiReset:FireClient(Officer, Victim)