Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I disable weapons in a Lobby?

Asked by 7 years ago

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:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local torso = char:WaitForChild('Torso')

torso.Touched:connect(function(hit)
    local human = hit.Parent:FindFirstChild('Humanoid') 
    if human.Parent.Name == 'BackpackChanger' then --the name of the block inside the Lobby.
        game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack,false)
    end
end)



Am I going about this the right way, or is there a better method? Thanks!

1 answer

Log in to vote
-1
Answered by 7 years ago

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:

function DisableBackpack() --Create a function to disable the backpack
    local StarterGui = game:GetService('StarterGui')
    StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
end

for i,v in next, game.Teams.Lobby:GetPlayers() do -- Getting the players in the lobby team
DisableBackpack()--Calls out the function only torwards the players in the lobby team
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

0
This code won't work. Did you even test it? Programical 653 — 7y
0
:) Thank you for the suggestion, but my game is not team-based, it wouldn't work for this game I don't think. My game is a "deathmatch" type of game. Players start in the Lobby, then teleport to the stage. Never2Humble 90 — 7y
Ad

Answer this question