Question… How do I make a player always have an item equipped? For example, make the item dynamite. How to make the player is constantly running with it in his hand and could not remove it? And the second task is how to make it so that in addition the player did not see his inventory. That is, this thing was not on his screen. But at the same time so that he has this item in his hand?
I’m on mobile right now so sorry I cannot write any code, if you do need help with it I’ll write it later.
You can listen to the .Unequiped event and use :EquipTool() on the humanoid to equip it again.
If I do remember correctly.
You can also just disable the backpack so they cant use it, meaning they cant unequip the tool
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Yeah, to extend, for the second part of the question but if you do disable the coregui for the inventory, make sure to :EquipTool manually.
Okay, I wrote this script in serverScriptService, but what should I write in the wait() loop? I want it to tell me every second to equip the item. But how exactly do I do that?
game.Players.PlayerAdded:Connect(function(player)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local tool = game:GetService("StarterPack")["TNT"]
while wait(1) do
end
end)
And on top of that, this line here for me personally does not disable backpack.
game.Players.PlayerAdded:Connect(function(player)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local tool = game:GetService("StarterPack")["TNT"]
--while wait(1) do
--end
end)
It has to be done in a LocalScript, not a ServerScript. Place a LocalScript in the StarterPlayer and paste it in there. Also, you don’t have to write game:GetService("StarterGui")
, its enough to just write game.StarterGui
To add,
Read up on CoreGuis here if you want a deeper understanding of what you are actually doing.
Most things GUI related are client side and are expected in LocalScripts, except if it poses a security threat to be handled there.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.