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)
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
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.
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.