[SOLVED] Disable Backpack, CoreGui by touching a certified Part

ISUUE: What I am trying to achieve is that when the Player would Touch a specific Part then the Backpack, CoreGui will disable. However, if the Player would Touch another Part then the Backpack, CoreGui will be enabled.

Script > StarterGui

local Player = game:WaitForChild("Players").LocalPlayer

local StarterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage"):WaitForChild("Handler (RS)"):WaitForChild("Events"):WaitForChild("VentEvent")
local Hide = ReplicatedStorage:WaitForChild("Hide")

local Postitions = game:GetService("Workspace"):WaitForChild("Vent"):WaitForChild("Postitions")
local InPos = Postitions:WaitForChild("InPos")
local OutPos = Postitions:WaitForChild("OutPos")

InPos.Touched:Connect(function(Touch)
	if Touch.Parent.Name == Player.Name then
		StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		print("Touched ".. InPos.Name)
	end
end)

OutPos.Touched:Connect(function(Touch)
	if Touch.Parent.Name == Player.Name then
		StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
		print("Touched ".. OutPos.Name)
	end
end)

just make sure it’s a localscript instead of a serverscript.

This script should work fine if it’s parented under StarterPlayerScripts, and is a LocalScript.

I have fixed the issue myself, no worry.

if anyone needs help with this feel free to ask.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.