How do you Make it where you Can Disable the Backpack CoreGUI and Add a ForceField

I have made the script but it seems to not want to work, is it that I added the CoreGUI part in the script that broke it? idk im trying to figure this out

local StarterGui = game:GetService("StarterGui")

script.Parent.Touched:Connect(function(SafeZone)
	if(SafeZone.Name ~= "HumanoidrootPart") then return end
	
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
	local character = SafeZone.Parent
	local forceField = Instance.new("ForceField")
	forceField.Visible = false
	forceField.Name = "safezone"
	forceField.Parent = character
end)


script.Parent.TouchEnded:Connect(function(SafeZone)
	if(SafeZone.Name ~= "HumanoidrootPart") then return end
	
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	local character = SafeZone.Parent
	local forceField = character:FindFirstChild("SafeZone")
	if(forceField) then
		forceField:Destroy()
	end
end)
1 Like

The r in HumanoidRootPart is a supposed to be a capital letter. (Roblox is case-sensitive)

yeah but how do you make both The GUI backpack and the forcefield work together

They should work together perfectly fine together, as I tested it, and it worked.

Do you have any errors in the output? Is this a LocalScript or server script?

What errors are you getting? It’s hard to fix bugs when you can’t see whats wrong with the script.

there isnt any errors which is weird i just think it doesn’t recognize the script

it is a Server Script. does it have to be local?

Yes, it has to be local. More specifically, StarterGui:SetCoreGuiEnabled() only works locally. Surprised you didn’t get any errors about this, because when I tried it on the server, it gave me an error.

Anyways, you can try to use a remote event to tell a LocalScript to enable/disable the backpack.

That makes the script Unuseable

Sorry, I don’t think I understand. Can you elaborate more on your statement? What do you mean by “Unusable”? Like the script still doesn’t work, or it doesn’t fit your needs, or something else.

if you look at the title im trying to make it where you Gain Inf health while also having your inventory disabled

I just tested it, and it worked like you wanted it to (based off of your code on your original post). I codded it so when the player touched a specific part, it gives the player a ForceField on the server, while disabling the backpack on the client. When the player stopped touching a specific part, the ForceField is removed, and the backpack is enabled again.

Can you please elaborate on “unusable” for your scenario, as it worked for me when I tested it.

(I can send the scripts I used to test if it helps!)