hey fellas.
im trying to make a player’s inventory disable when they hit a part, but re enable if they hit a different part.
here is my code:
local Players = game:GetService("Players")
local CoreGui = game:GetService("StarterGui") --the service
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Player") then
game.LocalPlayer.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end
end)
and the one that enables it:
local Players = game:GetService("Players")
local CoreGui = game:GetService("StarterGui") --the service
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Player") then
game.LocalPlayer.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end)
neither of these are working. What am i doing wrong?