Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to force player to hold items?

Hi guys, this is my first question and I am really new to scripting. How can I force a player to hold an item at all times? like they could switch items but could not hold nothing. Thanks for your help!

EDIT:

I have the code to do this, BUT removing the backpack means that I cant give players items in scripts. Anyone have alternate methods or ideas on how to do this???

EDIT #2:

How can players switch between multiple items with the backpack disabled? Anyone know how to do that with scroll or keybinds???

1 comment

0

Any help would be apreciated.

1 answer

Hello ChainMailZombie, you can disable the player's backpack using the StarterGui class. This will disable the player from using the default backpack system.

void SetCoreGuiEnabled (
    CoreGuiType coreGuiType,
    bool enabled
)

You can then call the SetCoreGuiEnabled function from the StarterGui object to disable the player's default backpack.

-- Grab reference to StarterGui so you can use the class from the Roblox's API
local StarterGui = game:GetService("StarterGui")

-- Disable the default backpack system
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

From there you can use the UserInputService that Roblox provides on there API to check for input events on the keyboard such as InputBegan or InputEnded.

It could get really complex or you can make it pretty basic with just keyboard input to change the player's current Tool. If you have more questions I would gladly help. I just gave you some hints on how to start your task.

10 comments

0

Would doing this mean that if a player got an item it would auto equip and not be able to be unequipped?

0

I tried putting the code in local and normal scripts and it gives a there should be an equal sign here red highlight for the first piece of code.

0

Yes it would make it so they cannot unequip a tool unless you setup a keybind and remove the tool from the character.

0

But what is wrong with the first line of code though? Should they be in separate scripts?

0

I got red line on the first on saying: Expected '=' got SetCoreETC.

0

Oh lol. That code will not work that is just the prototype in the API. Just look at the second block of code. 'StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)'

0

Lol

0

How can I give people items with the backpack broken?

0

And how can people swap between items??

0

Your privacy settings don't let me pm you

This discussion is preserved as it was. New answers, comments, and votes are closed.