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

Handle is not a valid member of Tool?

I was working on a game when suddenly my tool started giving an error

link to the layout

script:

local tool = script.Parent
local handle = tool.Handle --error here

local equiped = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local shootRemoteFunction = ReplicatedStorage.handPistoleShoot

tool.Equipped:Connect(function ()
    equiped = true
end)

tool.Unequipped:Connect(function ()
    equiped = false
end)

local function use(player)
    local ray = Ray.new(handle.CFrame.p, handle.CFrame.LookVector*5000)
    local BasePart, HitPosition, RayPosition, HitmaterialOrTerrain = workspace:FindPartOnRay(ray, player.Character)
    shootRemoteFunction:InvokeServer(HitPosition, BasePart, tool)
end

tool.Activated:Connect(use)
end

the error i get is Handle is not a vallid member of Tool

2 comments

0

Do not make 2 questions, it just clutters up the site.

0

sorry i did not know it got posted

1 answer

✓ Accepted answer

It is possible that the script loaded too quickly and the handle didn't appear.

local tool = script.Parent
local handle = tool:WaitForChild("Handle")

local equiped = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local shootRemoteFunction = ReplicatedStorage.handPistoleShoot

tool.Equipped:Connect(function ()
    equiped = true
end)

tool.Unequipped:Connect(function ()
    equiped = false
end)

local function use(player)
    local ray = Ray.new(handle.CFrame.p, handle.CFrame.LookVector*5000)
    local BasePart, HitPosition, RayPosition, HitmaterialOrTerrain = workspace:FindPartOnRay(ray, player.Character)
    shootRemoteFunction:InvokeServer(HitPosition, BasePart, tool)
end

tool.Activated:Connect(use)
end

1 comment

0

Thanks it fixed im new to scriping i will keep this in my head

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