Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't "Damage" called?

this is a damage script but when Damage == 1 it doesnt call it why?

wait(2)
Damage = 0
me = game.Players.LocalPlayer
Playa = game.Players.LocalPlayer
mouse = me:GetMouse()
Torso = me.Character.Torso
Head = me.Character.Head
Humanoid = me.Character.Humanoid
Neck = Torso["Neck"]
RightShoulder = Torso["Right Shoulder"]
LeftShoulder = Torso["Left Shoulder"]
RightHip = Torso["Right Hip"]
LeftHip = Torso["Left Hip"]
LeftArm = me.Character["Left Arm"]
RightArm = me.Character["Right Arm"]
LeftLeg = me.Character["Left Leg"]
RightLeg = me.Character["Right Leg"]
req = 50
on = 0



---- C MOVE--
PlayzUf = Playa.Name 
CMoveCD = true
mouse.KeyDown:connect(function(Key)
	if Key == "r" and CMoveCD == true  and Humanoid.Jump == false and on == 0 then
		local animation = Instance.new("Animation")
		animation.AnimationId = "http://www.roblox.com/item.aspx?id=321445347"
		local animTrack = Humanoid:LoadAnimation(animation)
		Damage = 1
		on = 1
		animTrack:Play()
		wait(2)
		Damage = 0
		on = 0
	end
end)
if Damage == 1 then
	print("lol")
	game.Players.LocalPlayer.Character["Right Leg"].Touched:connect(function(hit)
		if hit.Parent:findFirstChild("Humanoid") and hit.Parent.Name ~= me.Name then
		hit.Parent.Humanoid:TakeDamage(3)
		end
	end)
end

2 comments

0

hit.Parent:TakeDamage(3)

0

what about it

1 answer

✓ Accepted answer

Well I'm not going to punctiliously go through all your code, but I'll tell you where your logic is failing.

Basically, if statements only run once. Line 39 will be checked the first time the script runs, and never again.

I would recommend that you simply check the damage inside of the Touched event. This way the event will fire, but it won't do damage unless you tell it to. For example,

.Touched:connect(function(hit)
	if Damage == 1 then

	end
end)

1 comment

0

it works now

This discussion is preserved as it was. New answers, comments, and votes are closed.