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

Can Someone Ask Me what Is wrong With This Sword Kill Script And What i Should Add Or Remove?

Asked by 6 years ago

Yeah So For This Place I Am Making.I Am Making A Sword Kill Script.But I Keep On Getting Errors.I Also Keep On Removing And Adding Things And It's Really Getting On My Nerves.Can Someone Carefully Look Through The Code And Point Out What I Have Done Wrong?

Here Is The Script:

if game.Parent.Player.Humanoid.Health == 0 then
    if game.Player.Sword == game.Sword.Parent then   
        --Don't Know What I Am Doing Right Now
        game.Player.Sword.Parent (function(TouchedOn)
            if game.Sword.Player (TouchedOn) then
               game.Player.Humanoid (TouchedOn)
              game.Sword.Player.Humanoid (TouchedOn) .Health = 25 
            end
        end)
    end
end

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

I dont think one line of your code is functional, but you can try using this outline instead:

script.Parent.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
    if hum then
        hum.Health = hum.Health - 25
    end
end)

This would need to be in the sword handle part.

0
ok.I'll Put The Script In The Handle Part And Try That. RoccoAttackYT 8 — 6y
0
Thanks For The Answer.It Works And There Is No Errors.Though Next Time Can You Please Think About Whos Gonna Get Get Damaged.Because When My Character Picks It Up.He Loses 25HP.But Overall.Thanks Man,I Accept This Answer. RoccoAttackYT 8 — 6y
0
To make it where you can’t get damaged set a variable for script.Parent.Parent.humanoid and in the if statement right after hum out and not (variable you assigned to your humanoid) then. That should prevent your character from getting hit by it. cmgtotalyawesome 1418 — 6y
0
 youprevent your cmgtotalyawesome 1418 — 6y
Ad

Answer this question