Take Arsenal again as an example, you click deploy, you spawn with a gun. But how do you make it so that you cant unequip the tool only switch and spawn with it in your hand?
Put the tool in StarterPack.
Maybe. But that would make you manually click the tool. I need it to spawn with the tool, and unable to unequip and can switch
I don’t know about not being able to unequip, the only thing I can think about is either disabling the player’s inventory or detecting when the player unequips the tool then forcing the humanoid to equip it. If you want the humanoid to equip it immediately, try doing:
Humanoid:EquipTool(tool path goes here)
hmmm. If you disable the inventory, doesn’t that mean tools can’t go into the inventory since it’s disabled???
I mean disable the inventory ui by doing:
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Inventory, false)
it won’t make it so the inventory is deleted, it will only make it so that the player can’t open the backpack or see the hotbar and they can’t interact with anything inside of their inventory
Well, you need to disable the local client’s GUI by setting the CoreGui
’s Backpack Enum to false on a LocalScript
, which should be simple enough to do:
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Next you’d need to fire a RemoteEvent
to detect when the player clicks the “Play” button, so that they’re able to obtain the gun from the server side & use the EquipTool()
function to make the Player forcefully equip the chosen tool they have been given:
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local Button = script.Parent
Button.MouseButton1Down:Connect(function()
Event:FireServer()
end)
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(Player)
local StarterTool = game.ServerStorage.Tools.RandomTool:Clone()
StarterTool.Parent = Player.StarterGear
local Humanoid = Player.Character:WaitForChild("Humanoid")
Humanoid:EquipTool(StarterTool)
end)
Uh. It also supports mobile. I will probably need a custom switch button for mobile devices then
also the its a selection, like phantom forces where you choose your own guns. or big paintball* And I have the give gun thing done already.
Well we can’t really give you a whole script for that. You can use Humanoid:EquipTool() or weld it to the character.
wait. I can change the path. But does it allow you to unequip or switch?
yep. Well I’ll just find out about it by myself, doing some research
The knife’s gotta wait then. I will just try to make a switch for mobile and hopefully players can’t just press 1 and unequip
You could just save the chosen weapon that the player chooses in the selection screen, then fire that said “weapon” on the server for the Player to give
ContextActionService
moment, you can use those for mobile buttons
You’d need to implement your own Keybinds/GUI buttons to be able to do that, EquipTool()/UnequipTool()
only equips or unequips the current tool the Character is currently holding right now
I have seen people do something like Humanoid:UnequipTool() and then make a player equip a tool again.
edit: gotta go. I’ll just post a few things that might be easy but I get stuck on it.