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

How do I make a player on entry be forced to hold a specific tool?

I want to know how I would make a player on entry be forced to hold a tool that I desire.Sort of like when the player joins they will spawn with the tool I picked but they can not let go of it nor can they store it in their backpack with out using the tool.Kinda like they tool is stuck to their hand but they can still use it.

2 comments

0

do you want the tool to be spawned with the player? forever? and do you want to allow him to drop it?

0

Yes I want the tool to spawn with the player forever and no they cant drop it.

1 answer

For Force Equipping, you can try either one I listed below:

Inserting the tool to StarterCharacterScripts:

Anything inserted in StarterCharacterScripts will be parented to the player's character upon joining. Putting a tool in there will parent the tool to their character, forcing them to equip the tool.

Using Humanoid:EquipTool:

Humanoid:EquipTool(tool) will force a humanoid to equip the tool specified in the 'tool' parameter.

Example:

--SCRIPT:
game.Players.ChildAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local hum = char:FindFirstChild('Humanoid')
		hum:EquipTool(tool location)
	end)
end)

The above script will force a player to equip a tool(if tool location is specified) everytime they join, and everytime they respawn.

For Allowing players to unequip the tool, you can try either one I listed below:

Disabling the Backpack

Disabling the backpack will disallow players to equip, nor unequip tools.

You'll have to disable the backpack using: StarterGui:SetCoreGuiEnabled

--LocalScript
local starterGui = game:FindService('StarterGui')
starterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

Re-parenting the tool if unequipped

You'll have to re-parent the tool if unequipped. You can use Tool.Unequipped event to help

--A script in the tool and assuming we've already specified 'tool'

tool.Unequipped:Connect(function()
	local player = tool.Parent.Parent
	player.Character.Humanoid:EquipTool(tool)
end)

Hope this helped

1 comment

0

Thank you so much!

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