Hello DevForum! I am not a good scripter but I am trying to figure out how to make it so that when a player touches a part it disables their backpack. I tried to right my own code which might make me seem like a noob at scripting. And I understand that, but I just need some help getting this to work,
script.Parent.Touched:Connect(function(hit)
local char = hit.Parent
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
end)
But i guess it is a script server, so to disable the menu, player list or other player stuff you have to do it with a localscript.
So I suggest you once you get the char on the server to send an event to the client, and as soon as the client receives it, it disables the player’s backpack from the client.
I have tested it and it did not work. Nothing showed up in the output. My backpack wasn’t disabled. I feel like I did something wrong because it isn’t connecting.
This is the current Local Script:
game.Workspace.OptionEnable1:Connect(function(hit)
local char = hit.Parent
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
end)
Make sure your local script is under StarterPlayer > StarterPlayerScripts
Here’s an outlined fragment of code you can fill out
local StarterGui = game:GetService("StarterGui")
local player = game:GetService("Players").LocalPlayer
local part = game.Workspace.Part -- CHANGE THIS TO THE DIRECTORY OF THE PART
part.Touched:Connect(function(hit)
if hit.Parent == player.Character then
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end
end)
I hope this works and helps. If you have any questions feel free to comment under this