#dual wield tool fix

1 messages · Page 1 of 1 (latest)

unkempt cosmos
#

so ive been trying to make a tool that, when equipped, puts the player into a holding animation (as other weapons in my game work this way), however, i need help making it both make the guns appear and also play the animation. right now, when i hold the tool, nothing happens, but it disappears from my inventory.

unkempt cosmos
#

the gun has several parts in a model

#

and theyre all welded to the BodyAttach, which im pretty sure is jointed to the hand

placid hollow
#

what about other things like unanchoring and setting cancollide to false?

unkempt cosmos
#

all parts of the gun are cancollide false, and unanchored

placid hollow
#

do you have any errors?

unkempt cosmos
#

not sure if this is useful or not but, if i put the rig (the one im using to animate) in starterplayer as the StarterCharacter, he holds both guns (not in the animation, but theyre welded just fine to his hands

unkempt cosmos
#

if i make the rig the startercharacter, then the guns are welded to its hands

placid hollow
#

can add print statements to things like bodyAttachL and bodyAttachR to see if they even exist?

unkempt cosmos
#

sure

placid hollow
#

tell me what you got in the output then

unkempt cosmos
fossil slateBOT
#

studio** You are now Level 9! **studio

unkempt cosmos
#

assuming youd do it like this

#

it doesnt return anything when i equip the tool

placid hollow
#

oh so it doesnt event print?

unkempt cosmos
#

yeah, the output prints nothing

#

wait

#

hang on gimme a sec i think i know why its not printing

placid hollow
#

alr

unkempt cosmos
#

nevermind

#

i thought taking the objects out of the mode

#

l

#

would fix it

#

heres how the tool is set up

#

yet nothing prints

#

which is weird

placid hollow
#

this must mean that either the humanoid is nil or the function doesnt even fire

unkempt cosmos
#

i mean

#

i dont see how the humanoid can be nil

#

when its clearly there

#

and the function should fire

placid hollow
#

hmm

unkempt cosmos
#

thanks for helping btw man

placid hollow
#

np

#

can you print char:GetChildren() just to be sure?

unkempt cosmos
#

sure

placid hollow
#

on the top

unkempt cosmos
#

thats weird

#

surely there are more children

#

than just the two weapons

placid hollow
#

yeah thats weird

fossil slateBOT
#

studio** You are now Level 5! **studio

placid hollow
#

so it only prints the tools?

unkempt cosmos
#

yeah

#

even though char is defined as

#

tool.Parent

#

which is the character

#

as you can see

placid hollow
#

yeah

#

maybe try to add some task.wait() at the top? maybe it needs to load or something idk

unkempt cosmos
#

when i was testing

placid hollow
#

wait

#

i think i know why

#

where is the tool located before the game starts?

unkempt cosmos
#

StarterPack

hoary pecan
#

add a print if there is no humanoid before return

placid hollow
#

thing line right here, it sets the reference at the time the game starts, which means that the tool is actually StarterPack, not the tool

#

i think this is it

hoary pecan
#

Is the script under the tool?

placid hollow
unkempt cosmos
#

right*

unkempt cosmos
placid hollow
#

did it work?

hoary pecan
unkempt cosmos
#

sorry man mb

hoary pecan
unkempt cosmos
#

fire

#

idk why

placid hollow
#

rather that at the top

hoary pecan
unkempt cosmos
hoary pecan
#

Wait..

#

Tool.Equipped doesn't run on the server.

unkempt cosmos
placid hollow
unkempt cosmos
placid hollow
unkempt cosmos
unkempt cosmos
#

the function doesnt fire

placid hollow
#

ye youre right

#

thisdoesnt makes sense

unkempt cosmos
#

this is js so weird

placid hollow
#

alright so maybe lets go to the previous version of the script

hoary pecan
#

the problem mightbe on char

unkempt cosmos
#

where do i print char

#

cuz its defined in the function

#

that wont fire

hoary pecan
#

after char

hoary pecan
unkempt cosmos
#

yes

#

literally

#

i equip it

#

and nothing happens

hoary pecan
#

show me your current script

unkempt cosmos
hoary pecan
#

drop your code

unkempt cosmos
#

i did

#

its up there

hoary pecan
#

No i mean with text

#

So i can copy it

unkempt cosmos
#

ohh

#

alright

#

local tool = script.Parent

local function onEquipped()
print("fired")
local char = tool.Parent
local humanoid = char:FindFirstChildOfClass("Humanoid")
if not humanoid then
print("no humanoid found") return end

local rightHand = char:FindFirstChild("RightHand")
local leftHand = char:FindFirstChild("LeftHand")

local bodyAttachR = tool:FindFirstChild("BodyAttachR")
local bodyAttachL = tool:FindFirstChild("BodyAttachL")
print(bodyAttachL, bodyAttachR)


if rightHand and bodyAttachR then
    local m6d = Instance.new("Motor6D")
    m6d.Name = "RightGunM6D"
    m6d.Part0 = rightHand
    m6d.Part1 = bodyAttachR
    m6d.C0 = CFrame.new() 
    m6d.C1 = CFrame.new()
    m6d.Parent = rightHand
end

if leftHand and bodyAttachL then
    local m6d = Instance.new("Motor6D")
    m6d.Name = "LeftGunM6D"
    m6d.Part0 = leftHand
    m6d.Part1 = bodyAttachL
    m6d.C0 = CFrame.new()
    m6d.C1 = CFrame.new()
    m6d.Parent = leftHand
end

end

local function onUnequipped()
local char = tool.Parent
if not char then return end

local rightHand = char:FindFirstChild("RightHand")
local leftHand = char:FindFirstChild("LeftHand")

if rightHand then
    local joint = rightHand:FindFirstChild("RightGunM6D")
    if joint then joint:Destroy() end
end
if leftHand then
    local joint = leftHand:FindFirstChild("LeftGunM6D")
    if joint then joint:Destroy() end
end

end

tool.Equipped:Connect(onEquipped)
tool.Unequipped:Connect(onUnequipped)

hoary pecan
#

alr now use this

#

and tell me what it prints on output

#

Wait

unkempt cosmos
#

literally nothing

hoary pecan
#

the problem is not the code.

unkempt cosmos
#

nothing gets printed

#

so the problem s prolly the tool

hoary pecan
#

the problem is the tool!

#

does the tool have a handle?

unkempt cosmos
unkempt cosmos
#

waiit

#

i thought RequiresHandle was off

#

😭

#

ok lemme try now

hoary pecan
#

Disable this

#

YESSS

unkempt cosmos
#

HUZZAH

#

now the issue is this

#

with the local script

#

which is weird since

hoary pecan
#

so does the other script work

unkempt cosmos
#

the anim is in there

unkempt cosmos
#

since the second i equip the tool

#

it returns the error

#

with local

hoary pecan
#

Dumbass ofc play is not a valid member of animation look closely you said anim:Play() which is an animation you have to play the track not the anim

#

lol

unkempt cosmos
#

AYYYYYYYY

#

IT WORKS

#

THANK YOU

#

appreciate u sm bro

hoary pecan
#

the other script works too?

unkempt cosmos
#

😭

unkempt cosmos
hoary pecan
#

alr then

#

That would be 1k robux

unkempt cosmos
#

thanks a ton man

unkempt cosmos
hoary pecan
#

💀 nah nvm

#

anyways cya

unkempt cosmos
#

seeya bro

#

hangon is there a way i can

#

+rep you