I made a script I'm very pleased with that fires an orb from a wand tip to the mouse location, but I noticed it also works with other tools out and no tool at all. Can I get a hint or some guidance as to how I can make sure that this script only runs when this tool is out? Thanks Immediately below is the hierarchy StarterWand(Tool) > Main(LocalScript) > MAIN(Script) and UseWand(RemoteEvent) StarterWand> Handle(Part) and Stick(Part)
Main:
wait (1.0)
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
function Clicked (mouse)
script.UseWand:FireServer()
end
function ConnectFunction (mouse)
Mouse.Button1Down:connect(Clicked)
end
script.Parent.Equipped:Connect(ConnectFunction)
MAIN:
local mouse = game.Players.LocalPlayer:GetMouse() -- allows us to see what the mouse is doing
local debounce = false
script.Parent.UseWand.OnServerEvent:Connect(function(Player) -- create a function for when the tool is used. No name needed for the function since it is called upon on a server event.
if debounce == false then
debounce = true
wait(.5)
local Orb = game.ReplicatedStorage.Small:Clone() -- create a part called orb that is exactly like the part in replicated storage called small
Orb.CFrame = script.Parent.Parent.Handle.CFrame*CFrame.new(0 ,1.6, 0) -- give the orb a reference point to spawn from, this is at the origin of the handle
Orb.Parent = game.Workspace -- make sure the part's parent is workspace so it is in the workspace
local BV = Instance.new("BodyVelocity", Orb) -- give it a body velocity so that it may move
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge) -- Give the body velocity a maximum force to not exceed
BV.Velocity = (mouse.Hit.p - Orb.Position).unit * 65 -- velocity is position and speed so I have it a position, the players mouse and a speed of 65
local alreadytouched = false
Orb.Touched:connect(function(hit)
if alreadytouched == false then
local human = hit.Parent:FindFirstChild("Humanoid")
if human ~= nil and human.Parent ~= Player.Character then
human:TakeDamage(10)
alreadytouched = true
end
end
end)
wait (.5)
debounce = false
end
end)
Please and thank you, I'm still learning :D

4 comments
Please use a "Code Block" for each of the scripts.
And... what you meant is... to detect if the player has selected the tool?
Sorry I updated it. I meant that currently the script is shooting the orb when I left click no matter what the player is holding and I want it to only shoot when they have this tool in their hands.
I think I get it, I had this problem when I made some guns. So, I made a bool value, so I made the script below. youll have to clean it up.