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

How to force player to hold items?

Asked by 6 years ago
Edited 6 years ago

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???

0
Any help would be apreciated. ChainMailZombie 0 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

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.

0
Would doing this mean that if a player got an item it would auto equip and not be able to be unequipped? ChainMailZombie 0 — 6y
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. ChainMailZombie 0 — 6y
0
Yes it would make it so they cannot unequip a tool unless you setup a keybind and remove the tool from the character. Impacthills 223 — 6y
0
But what is wrong with the first line of code though? Should they be in separate scripts? ChainMailZombie 0 — 6y
View all comments (6 more)
0
I got red line on the first on saying: Expected '=' got SetCoreETC. ChainMailZombie 0 — 6y
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)' Impacthills 223 — 6y
0
Lol ChainMailZombie 0 — 6y
0
How can I give people items with the backpack broken? ChainMailZombie 0 — 6y
0
And how can people swap between items?? ChainMailZombie 0 — 6y
0
Your privacy settings don't let me pm you ChainMailZombie 0 — 6y
Ad

Answer this question