Disabling Backpack script does not work

Hello forums, i am developing a fps game that include a downed system inside the game. Basically, i want the player’s backpack to be disabled whenever they’re downed. So far i have finished the unequip script that activate when you are downed. However, i can’t get this script below to work for some particular reason. Can anyone help?

(isdown is a boollean value that become true when you’re downed)

game.Players.PlayerAdded:Connect(function(p)
	p.CharacterAdded:Connect(function(c)
		local humanoid = c:WaitForChild("Humanoid")
		humanoid:GetPropertyChangedSignal("Health"):Connect(function()
			if humanoid.Health == 100 and c.isdown == true then
				game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
				print("backpack disabled")
			else
				game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
			end
		end)
		
	end)
end)
1 Like

Is this a Server Script or a Client Script?

You must use .Value to access the value of a BoolValue.

You can also only call SetCoreGuiEnabled on the client, so if it is the server, that might be an issue.

If it is the client, though, I don’t see the need to set the gui for every other player.

4 Likes

To convert it into a client script you can just do

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

local humanoid = Char.WaitForChild("Humanoid")
		humanoid:GetPropertyChangedSignal("Health"):Connect(function()
			if humanoid.Health == 100 and c.isdown == true then
				game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
				print("backpack disabled")
			else
				game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
			end
		end)

And just put this inside of starter player scripts

3 Likes

Yes sorry for being late, i did forgot the .Value thing but the script is a client script. I tried it and it still doesn’t work out

1 Like

It didn’t work, i tried replacing c with Char and added .Value just like koip said. Though, i noticed that the print function didn’t appear in the console when the condition to hide backpack was met which is really weird.

1 Like

Nevermind! I got it worked
Apparently i forgot the .Value and placed it into the wrong place.

Here’s the script for anyone who wanted it

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local humanoid = Char:WaitForChild("Humanoid")

humanoid:GetPropertyChangedSignal("Health"):Connect(function()
	if humanoid.Health <= 100 and Char.isdown.Value == true then
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		print("backpack disabled")
	else
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
	end
end)

Thank you 12345koip and KingBob for helping me out! Good day to you two.

2 Likes

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