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

Workspace.Dummy.Controller.Attack:17: attempt to index nil with 'WalkSpeed' ?

Asked by 3 years ago
Edited 3 years ago

local attackCooldown = 1 local attackWindup = 0.5 local attackRange = 3 local attackDamage = 20

local char = script.Parent.Parent local hum = char:WaitForChild("Humanoid") local originalWalkSpeed = hum.WalkSpeed

local canAttack = true

script.Parent.AttackRemote.Event:Connect(function(plrRoot)

01if not canAttack then return end
02canAttack = false
03 
04hun.WalkSpeed = 0.1
05 
06local anim = Instance.new("Animation")
07anim.AnimationId = "rbxassetid://7209529782"
08local playAnim = hum:LoadAnimation(anim)
09playAnim:Play()
10 
11wait(attackWindup)
12local newDistance = (char.HumanoidRootPart.Position - -plrRoot.Position).magnitude
13if newDistance <= attackRange + 5 then
14 
15    if plrRoot.parent.Player.isBlocking.Value == true then
View all 25 lines...

2 answers

Log in to vote
0
Answered by
D4_rrk 89
3 years ago

Lua is case sensitive, so you need the 's' to be also capitalized.

1hun.WalkSpeed = 0.1
0
still broke OpticsOnline 6 — 3y
0
You also misspelled WalkSpeed with WalkSpeen and originalWalkSpeed with orininalWalkSpeed. It should be hum.WalkSpeed = originalWalkSpeed D4_rrk 89 — 3y
0
In the future, if you get errors make sure to re-read your code to make sure any capitals are capitalized and any misspellings are changed. D4_rrk 89 — 3y
0
yeah, i fixed all that and it still doesnt work. OpticsOnline 6 — 3y
View all comments (9 more)
0
What is the error message that you have gotten now? D4_rrk 89 — 3y
0
same error massage OpticsOnline 6 — 3y
0
just with caps OpticsOnline 6 — 3y
0
Workspace.Dummy.Controller.Attack:17: attempt to index nil with 'WalkSpeed' OpticsOnline 6 — 3y
0
Would you mind providing me with the line of code where the error appears. You can do this by clicking on the error message and it will direct you to the line of code where the error occurred. D4_rrk 89 — 3y
0
hun.WalkSpeed = 0.1 OpticsOnline 6 — 3y
0
You misspelled hum with hun. So it should be hum.WalkSpeed = 0.1 D4_rrk 89 — 3y
0
I hope this solved your issue. D4_rrk 89 — 3y
0
tysm OpticsOnline 6 — 3y
Ad
Log in to vote
0
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

Problem:

You are trying to set a value of a misspelled variable, and failed to capitalize the 'S' in hum.WalkSpeed.

Solution:

Fix the misspelled words and capitalization.

Code:

01local attackCooldown = 1
02local attackWindup = 0.5
03local attackRange = 3
04local attackDamage = 20
05 
06local char = script.Parent.Parent
07local hum = char:WaitForChild("Humanoid") -- the variable you defined
08local originalWalkSpeed = hum.WalkSpeed
09 
10local canAttack = true
11 
12script.Parent.AttackRemote.Event:Connect(function(plrRoot)
13    if not canAttack then return end
14        canAttack = false
15 
View all 37 lines...
0
how do i spell it correctly? OpticsOnline 6 — 3y

Answer this question