You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want the script to work with my custom characters
What is the issue? Include screenshots / videos if possible!
I made a toy hammer which when equipped, kills NCPs. It works with roblox avatars but doesnt seem to work with my custom characters. I have welded the tool onto my custom characters right hand and it equips and unequips fine. Its just not calling up my slash animation etc or doing anything.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked on dev hub but the problems only seem to be about equipping the tool - which ive done as a weld and that works fine. My code is below. I would like some guidance on which part may not be working due to changing to a custom character - my character animations have been put into the generic Roblox Animate script and values etc- ive got all other animations working fine using this method.
-- This is an example Lua code block
local tool = script.Parent
local canDamage = false
local sound = script.Parent.BOING
local debounce = false
local function onTouch(otherPart)
wait(6)
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if not otherPart or not otherPart.Parent or game.Players:GetPlayerFromCharacter(otherPart.Parent) then
sound:Play()
return end
if humanoid.Parent ~= tool.Parent and canDamage then
sound:Play()
humanoid:TakeDamage(50)
else
return
end
if not debounce then
debounce = true
wait(2)
debounce = false
canDamage = false
end
end
local function slash()
local str = Instance.new("StringValue")
str.Name = "toolanim"
str.Value = "Slash"
str.Parent = tool
canDamage = true
end
tool.Activated:Connect(slash)
tool.Handle.Touched:Connect(onTouch)
Please do not ask people to write entire scripts or design entire systems for you. If you canât answer the three questions above, you should probably pick a different category.
The tool animations (none, slash and lunge) are designed for R6/R15 avatars specifically, for them to be compatible with your custom rig, your custom rig will need limbs that match those of either R6 or R15.
Thank you for your reply. My character has been rigged exactly the same except Iâve welded a joint from the tool to its hand. Could it be this weld that is stopping it from working?
Is your problem the tools not attaching to your custom characters? It could be because your character dosent have a RightGripAttachment in the right hand. If you look in the right hand of a normal Roblox character, you will see a RightGripAttachment.
I tried the right hand grip but it didnât work so I settled to welding it as a joint. My character equips and unequips it but the script has stopped working. Is it because the script isnt recognising it as a right hand grip attachment therefore itâs classing it as unequipped?
I changed the animation ID in the Roblox animation script (R15) is there no way of overriding it this way like one can with the run, jump etc animations? I managed to override the toolnone animation by putting in my own animation ID.
I see the problem. Your line of code here: if not otherPart or not otherPart.Parent or game.Players:GetPlayerFromCharacter(otherPart.Parent) then logically says âif the character belongs to a playerâ, which in this case it does ââŚdo nothing and just ignore itâ. Change it to: if not otherPart or not otherPart.Parent then to fix the problem.
I wonât be able to get on studio tonight. But youâll only see my character equip the tool and then do nothing with it when I click the mouse button so nothing much to see apart from my character with his tool equipped.
This problem has to be something to do with letting my animation script know that my character has it equipped.
But the custom character was a player. If you add a StarterCharacter, it will be linked to the player. If you want it to work, you must find a workaround.
I would recommend a value in the character, presumably called IsNotPlayer or something like that, to bypass the if statement you set up.
Sorry, There is actually an error - i thought that there wasnt when i replied to you. From my understanding - it seems it is not recognising my Character as the humanoid because there isnt a hand grip so im guessing - since i cant put a working hand grip in a custom character (tell me if im wrong), i need to let the script know that the tool is equipped and my character is the parent? The error reads as:
Workspace.Dummy.Emoji Hammer.Damage:25: attempt to index nil with âParentâ - Server - Damage:25
The error is because humanoid in the variable specified is not assigned. You added a wait(6), so is the other character dying? If the character dies, the Humanoid cannot be found. If this really is the problem, you can either increase respawn time or remove the wait statement.
The character is not the humanoid. You didnât add a statement to prevent the error. I would recommend if not humanoid then return end or something, and possibly print out some debugging data.
That shouldnât matter at all.
So anyways, I think removing the wait statement and adding that extra error catcher might solve the problem. I did notice sound:Play() plays anyways so Iâm not sure if thatâs intentional, but I think the script is coded nicely. I would also replace otherPart.Parent:FindFirstChild("Humanoid") with otherPart.Parent:FindFirstChildWhichIsA("Humanoid") as it doesnât care what the Humanoid is named.
Thankyou, ive made that change now but it still doesnt work. Ive taken the weld off to see what happens and my tool doesnt come out but my characters toolnone animation plays with no tool in my hand. Its just not detecting that im holding the tool.
I have some experience with tools, but what Iâve done to get a sword-like animation to play is renaming the Handle to handle, which gets toolnone to play. So, is your Handle named âHandleâ?
Also, is RequireHandle set to false? If there is no handle (named âHandleâ), this should be false.