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

My script wont work?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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)

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. slenderfoo 0 — 10y
Ad

Answer this question