of     1   

TylerDoesScripting
#183457940Friday, February 12, 2016 10:46 PM GMT

I'm having trouble with this script because it works in studio, but no in game, if you have helpful tips or fixes please reply. It says in the output that character is nil- I tried all the services. --Place in StarterPack, ignore the damage function and box,c.Part, no problem with those local Energized = true plr = script.Parent.Parent c = plr.Character hum = c.Humanoid m = plr:GetMouse() Torso = c.Torso Run = game:GetService("RunService") RS = Torso["Right Shoulder"] LS = Torso["Left Shoulder"] PunchSound = script.PunchSound local combo = 0 OverHeadKick = script:WaitForChild("OverHeadKick") SpinKick = script:WaitForChild("SpinKick") Punch = script:WaitForChild("Punch") hithumanoids = {} box = c.Part function onDamage(hit) if hit.Parent.Humanoid then local targethumanoid = hit.Parent.Humanoid if targethumanoid and targethumanoid.Health>0 and not hithumanoids[targethumanoid] then hithumanoids[targethumanoid] = true targethumanoid:TakeDamage(25) end end end m.KeyDown:connect(function(k) if not Energized then return end Energized = false k = k:lower() if k == "q" then print("Well, it detected the key?") local SpinKickAnim = hum:LoadAnimation(SpinKick) local OverHeadKickAnim = hum:LoadAnimation(OverHeadKick) local PunchAnim = hum:LoadAnimation(Punch) if plr and c and hum and hum.Health>0 and PunchAnim and combo == 0 then print("There's a problem?") PunchAnim:Play() PunchSound:Play() box.Touched:connect(onDamage) combo = 1 elseif plr and c and hum and hum.Health>0 and SpinKickAnim and combo == 1 then print("Is there a failure?") SpinKickAnim:Play() PunchSound:Play() box.Touched:connect(onDamage) combo = 2 elseif plr and c and hum and hum.Health>0 and OverHeadKickAnim and combo == 2 then print("WHAT'S GOING ON?") OverHeadKickAnim:Play() PunchSound:Play() box.Touched:connect(onDamage) combo = 0 end end wait(0.4) Energized = true Energized = true end)
TylerDoesScripting
#183458182Friday, February 12, 2016 10:49 PM GMT

There are four animations and a sound in the script, so add those and rename the animations to OverHeadKick, Punch, and SpinKick. Rename the sound to PunchSound
badguy1233
#183459503Friday, February 12, 2016 11:03 PM GMT

Use a LocalScript
TylerDoesScripting
#183508913Saturday, February 13, 2016 3:56 PM GMT

I know that to use a LocalScript, the script is a LocalScript, thank you tho :P
JarodOfOrbiter
#183509009Saturday, February 13, 2016 3:58 PM GMT

You need to wait for the character to load. local c = plr.Character or plr.CharacterAdded:wait()
TylerDoesScripting
#183510248Saturday, February 13, 2016 4:14 PM GMT

Yes I know I added that to the script already, still doesn't work. I've tried a similar method and this one. Same output: 10:14:31.169 - Humanoid is not a valid member of Model 10:14:31.170 - Script 'Players.Player1.Backpack.Combat', Line 6 10:14:31.170 - Stack End
indeimaus
#183510280Saturday, February 13, 2016 4:15 PM GMT

it might be a problem with how you're getting plr. since the script is a localscript you can use local player. replace "plr = script.Parent.Parent" with "plr = game:GetService('Players').LocalPlayer"
TylerDoesScripting
#183510591Saturday, February 13, 2016 4:20 PM GMT

Here's the new script so far: local Energized = true local plr = game:GetService('Players').LocalPlayer local c = plr.Character or plr.CharacterAdded:wait() hum = c.Humanoid m = plr:GetMouse() Torso = c.Torso Run = game:GetService("RunService") RS = Torso["Right Shoulder"] LS = Torso["Left Shoulder"] PunchSound = script.PunchSound local combo = 0 OverHeadKick = script:WaitForChild("OverHeadKick") SpinKick = script:WaitForChild("SpinKick") Punch = script:WaitForChild("Punch") hithumanoids = {} function onDamage(hit) if hit.Parent.Humanoid then local targethumanoid = hit.Parent.Humanoid if targethumanoid and targethumanoid.Health>0 and not hithumanoids[targethumanoid] then hithumanoids[targethumanoid] = true targethumanoid:TakeDamage(25) end end end m.KeyDown:connect(function(k) if not Energized then return end Energized = false k = k:lower() if k == "q" then print("Well, it detected the key?") local SpinKickAnim = hum:LoadAnimation(SpinKick) local OverHeadKickAnim = hum:LoadAnimation(OverHeadKick) local PunchAnim = hum:LoadAnimation(Punch) if plr and c and hum and hum.Health>0 and PunchAnim and combo == 0 then PunchAnim:Play() PunchSound:Play() combo = 1 elseif plr and c and hum and hum.Health>0 and SpinKickAnim and combo == 1 then SpinKickAnim:Play() PunchSound:Play() combo = 2 elseif plr and c and hum and hum.Health>0 and OverHeadKickAnim and combo == 2 then OverHeadKickAnim:Play() PunchSound:Play() combo = 0 end end wait(0.4) Energized = true Energized = true end) Same output sadly: 10:20:09.465 - Humanoid is not a valid member of Model 10:20:09.465 - Script 'Players.Player1.Backpack.Combat', Line 6 10:20:09.466 - Stack End
JarodOfOrbiter
#183510788Saturday, February 13, 2016 4:22 PM GMT

local h = c:WaitForChild("Humanoid")
TylerDoesScripting
#183510934Saturday, February 13, 2016 4:24 PM GMT

When I do different methods, the 'errors' in the output aren't there but the LocalScript still doesn't work.
TylerDoesScripting
#183511014Saturday, February 13, 2016 4:26 PM GMT

OMG, YES IT WORKED, I DIDN'T KNOW THIS WOULD WORK THANK YOU
indeimaus
#183511057Saturday, February 13, 2016 4:26 PM GMT

try findFirstChild() and don't use keydown because it's deprecated
TylerDoesScripting
#183511066Saturday, February 13, 2016 4:27 PM GMT

Thanks for all your help and participation. :D
cheesecake123456
#183511134Saturday, February 13, 2016 4:27 PM GMT

Idk: local plr = game.Players.LocalPlayer repeat wait() until plr:FindFirstChild('Character') local c = plr.Character repeat wait() until c:FindFirstChild('Humanoid') hum = c.Humanoid
TylerDoesScripting
#183511153Saturday, February 13, 2016 4:28 PM GMT

The combat now works in-game, thank you guys
TylerDoesScripting
#183511518Saturday, February 13, 2016 4:33 PM GMT

If you want to check out the combat animation(no damage yet) join here: http://www.roblox.com/games/362142436/Combat Press Q for combat.
indeimaus
#183513677Saturday, February 13, 2016 5:06 PM GMT

"Torso is not a valid member of Model"- the output in your game

    of     1