Hello!
I'm trying to disable the weapons in a player's backpack while inside the lobby. But I'm having a bit of trouble with that. I've tried a couple of different scripts, without much luck. I've tried to do this by putting a giant invisible block inside my Lobby and inserting a local script to where if the player is touching the block, their backpack will be disabled.
This is my most recent scripting attempt:
01 | local player = game.Players.LocalPlayer |
02 | local char = player.Character or player.CharacterAdded:wait() |
03 | local torso = char:WaitForChild( 'Torso' ) |
04 |
05 | torso.Touched:connect( function (hit) |
06 | local human = hit.Parent:FindFirstChild( 'Humanoid' ) |
07 | if human.Parent.Name = = 'BackpackChanger' then --the name of the block inside the Lobby. |
08 | game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false ) |
09 | end |
10 | end ) |
Am I going about this the right way, or is there a better method? Thanks!
Your way could work, but i do have another way that might be a little easier. You could create a "Lobby" team, and then, when a player is in the Lobby team, you could disable the player's backpack. Here's an example:
1 | function DisableBackpack() --Create a function to disable the backpack |
2 | local StarterGui = game:GetService( 'StarterGui' ) |
3 | StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false ) |
4 | end |
5 |
6 | for i,v in next , game.Teams.Lobby:GetPlayers() do -- Getting the players in the lobby team |
7 | DisableBackpack() --Calls out the function only torwards the players in the lobby team |
8 | end |
Then again, you dont have to use this method, depending on your goals of the game you are making, but this is the way i would go about doing so. Please accept my answer if this helped! ;)
--Seabiscuitz