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.
#dual wield tool fix
1 messages · Page 1 of 1 (latest)
did you rig the gun properly?
i think so
the gun has several parts in a model
and theyre all welded to the BodyAttach, which im pretty sure is jointed to the hand
what about other things like unanchoring and setting cancollide to false?
all parts of the gun are cancollide false, and unanchored
do you have any errors?
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
sadly not
if i make the rig the startercharacter, then the guns are welded to its hands
can add print statements to things like bodyAttachL and bodyAttachR to see if they even exist?
sure
tell me what you got in the output then
** You are now Level 9! **
oh so it doesnt event print?
yeah, the output prints nothing
wait
hang on gimme a sec i think i know why its not printing
alr
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
this must mean that either the humanoid is nil or the function doesnt even fire
i mean
i dont see how the humanoid can be nil
when its clearly there
and the function should fire
hmm
thanks for helping btw man
sure
on the top
yeah thats weird
** You are now Level 5! **
so it only prints the tools?
yeah
even though char is defined as
tool.Parent
which is the character
as you can see
yeah
maybe try to add some task.wait() at the top? maybe it needs to load or something idk
i tried that
when i was testing
StarterPack
add a print if there is no humanoid before return
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
Is the script under the tool?
shiiiii
ur eight
yeah
right*
yeah man
did it work?
if the tool is in starterpack its added to the backpack automatically so no need.
try printing before return
reference tool in the onEquipped function
rather that at the top
thats why i'm saying this
i put a print in
like this?
yeah
what does this mean?
it does run, we tested it like 5 minutes ago
the tool doesnt recognise itself as being equipped
huh
this is js so weird
alright so maybe lets go to the previous version of the script
and print char.Name
the problem mightbe on char
after char
and how do u know it doesn't did u add a print on top of the function?
show me your current script
drop your code
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)
literally nothing
the problem is not the code.
great!
it doesnt, however
waiit
i thought RequiresHandle was off
😭
ok lemme try now
so does the other script work
the anim is in there
nothing gets outputted
since the second i equip the tool
it returns the error
with local
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
the other script works too?
😭
yes lmaoo
thanks a ton man
i have 12 will that suffice 😭 🙏🏿