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

What script will make this check if they have the tool equipped?

I need it so that the game checks if they have the tool equipped, and if they do, upon hitting 'Q' it will fire a ball with particles on it, causing an explosion. Help!

2 answers

First, you will need an equipped value (Boolean value) and a string value. 1.Name the Boolean value holding, and the String value owner. 2.Use this code:

local player = script.Parent.Parent.Name --Do parent until it reaches the player (not character)
script.Parent.Equipped:connect(function(mouse) --parent until it reaches the TOOL
script.Parent.owner.value = player
wait(0.1) --give it time to work 0.1 seconds
if script.Parent.Parent == player then
script.Parent.holding.Value = true  --Make sure the code knows it is equipped
--insert fireball code here
else
print("Player is not holding this weapon")
script.Parent.holding.value = true
end)

Noobish scripter here, I know how to, but not that much.

1 comment

0

I literally know about 1/10 of scripting. First time here

Local script

local player = game.Players.LocalPlayer
for i,v in pairs(player.Character:GetChildren()) do
	if v:IsA("Tool") then
		print("Player has the tool: " .. v.Name .. " currently equipped!")
	end
end

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