Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix this? Animation + Tool the error im getting is attempt to index nil with 'Parent' [closed]

Asked by 4 years ago
Edited by JesseSong 4 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

in case you cant copy here is raw paste https://pastebin.com/raw/6jC7hnzn Edited


local tool = script.Parent local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character while character.Parent == nil do character.AncestryChanged:Wait() end local leaderstats = player.leaderstats local cooldown = 2 local ready = true local humanoid = character:WaitForChild("Humanoid") local animation = tool.Animation local animationTrack = humanoid:LoadAnimation(animation) tool.Activated:Connect(function() if ready == true then animationTrack:Play() --animationTrack.Looped = true print("Animation Played!") leaderstats.Strength.Value = leaderstats.Strength.Value + 1 print("Strength Added!") ready = false animationTrack:Stop() wait(cooldown) print("Cooldown Done!") ready = true end end)

Don't ever delete what a moderator has added on your question, or it will get moderated!

Error: attempt to index nil with 'Parent

[Edit by JesseSong:] Tip use a codeblock when answering questions, as it makes it easier and legible for us to read.

0
in case you cant copy here is raw paste https://pastebin.com/raw/6jC7hnzn PurpleSouley1234 43 — 4y
0
Try inputting this line of code after you declare the character variable: https_KingPie 0 — 4y
0
test https_KingPie 0 — 4y
0
(Having trouble getting the formatting down - try pasting this code block right after you declare the variable "character" https://pastebin.com/raw/kb0dXH8N https_KingPie 0 — 4y
View all comments (2 more)
0
it doesn't give me error anymore but animation wont play PurpleSouley1234 43 — 4y
0
nvm it sill gives me the same error PurpleSouley1234 43 — 4y

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?