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

How to give players tools with a click detector?

I am trying to give the player a tool when they click on the torch, and then delete the model in workspace.

The script isn't reporting any errors, but my character either isnt getting the torch or isnt equipping it. I have all the GUI disabled so i cant open the backpack while playing, but i want the character to be holding the torch when it is given to them. Here is the script so far:

EDIT: After investigating a bit the problem is it is in the players backpack, but they are not equipping it. Is there a way I can force the player to equip it and not be able to unequip it?

Note: I want to keep the backpack, this way I can end up deleting the torch if I need to replace it with another tool. If there is no other way around this then another way is excepted

ToolName = "ModelTorch"

function grab(Player)
	if not Player.Backpack:FindFirstChild("ModelTorch") then
		local i = game.Lighting.ModelTorch:Clone()
		i.Parent = Player.Backpack
	end
end
script.Parent.ClickDetector.MouseClick:Connect(grab)

I want the character to be holding it when it is given. Could someone help me?

I'm successful in deleting the model if anyone wants that script. this one has no problems in it from what I can tell.

ToolName = "ModelTorch"

function delete(Player)
	wait(.001)
	if Player.Backpack:FindFirstChild("ModelTorch") then
		local e = workspace.touchTorch1
		e:Destroy()
	end
end
script.Parent.ClickDetector.MouseClick:Connect(delete)

4 comments

0

touchTorch1 is the name of the model that looks like the tool im using.

0

is the script local?

0

for equipting it just put the cloned tool in the character

0

Look up “Humanoid:EquipTool”

1 answer

I found ungrouping the model to work. Sorry if I am late! Also Changing Clone to Destroy.

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