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

My script wont work?

Ok so I made this skill script the skill works fine but for some reason it does damage to me when I use it so can someone take a look at it and help me? I wanted it to do damage to the other players.

Player = game.Players.LocalPlayer
Char = Player.Character
Torso = Char.Torso
Mouse = Player:GetMouse()

function Move(key)
	key = key:lower()
	if key == "z" then
		print ("z was pressed")
		game.Players.LocalPlayer.Character.Torso.Anchored = true
		for i = 1, 100, 3 do		
			Move = Instance.new("Part")
			Move.Parent = Workspace
			Move.Size = Vector3.new(math.random(4,6), math.random(4,6), math.random(4,6))
			Move.Anchored = true
			Move.TopSurface = 0
			Move.BottomSurface = 0
			Move.BrickColor = BrickColor.new("Brown")
			Move.CanCollide = false
			game.Players.LocalPlayer.Character.Torso.Anchored = false
			game.Players.LocalPlayer.Character.Humanoid:TakeDamage(1)
			y = Instance.new("BodyVelocity")
		    y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		    y.velocity = Player.Character.Torso.CFrame.lookVector*80
		    Move.Parent = Workspace
		    y.Parent = Move
    	    Move.CFrame = Player.Character.Torso.CFrame*CFrame.new (0, 0, -12)*CFrame.new (0,0,-i)CFrame.Angles(math.random(), math.random(), math.random())
			wait()			
		end
	end
end
Mouse.KeyDown:connect(Move)

1 answer

Line 21:

game.Players.LocalPlayer.Character.Humanoid:TakeDamage(1)

You pretty explicitly damage the local player.


What do you mean by "other" players, though? You don't have anything like that in this script.

If it's ones that you hit, you should attach an Touched event listener to each part in the local player's character, and damage any characters that touch it (by using the touching part's parent and looking for a humanoid)

1 comment

0

I mean I want it to damage the player it's hitting not the one that's using it. When I use the move on a dummy it damages me instead of it. So that's what I needed help with.

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