Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

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

Asked by 7 years ago

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!

Marked as Duplicate by KingLoneCat, davness, and TheHospitalDev

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Admin8483 -21
7 years ago

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.

0
I literally know about 1/10 of scripting. First time here DarkAssasin0 0 — 7y
Ad
Log in to vote
-1
Answered by 7 years ago

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