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

How to get a sword to do Self-Infliction and then Loop?

Asked by 10 years ago

So I want my sword to be special and if you like don't have permission to not get harmed by the sword you get hurt for holding it... But I don't think the script I've made is right... But this is all I could think of. I don't know how to loop either, so could someone help with that?

-- list of account names allowed to go through the door.
permission = { "MasterPoke99" } -- This is how many people can still get through, so u don't have to change shirts. You can also have another friend here. -EDIT

-- TextureId of the VIP shirt.
texture = "http://www.roblox.com" -- EDIT
function checkOkToLetIn(name) 
    for i = 1,#permission do 
        -- convert strings to all upper case, otherwise we will let in 
        -- "Username" but not "username" or "uSERNAME" 
        if (string.upper(name) == string.upper(permission[i])) then return true end 
    end 
    return false 
end 

local Door = script.Parent

function onTouched(hit) 
    print("Door Hit") 
    local human = hit.Parent:findFirstChild("Humanoid") 
    if (human ~= nil ) then 
        if human.Parent.Torso.roblox.Texture == texture then --the shirt 
            Door.Transparency = 0 
            Door.CanCollide = true 
            wait(.1) -- this is how long the door is open 
            Door.CanCollide = true 
            Door.Transparency = 0 
            -- a human has touched this door! 
            print("Human touched Poison Blade") 
            -- test the human's name against the permission list 
        elseif (checkOkToLetIn(human.Parent.Name)) then 
            print("Human passed test") 
            Door.Transparency = 0
            Door.CanCollide = true 
            wait(.1) -- this is how long the door is open
            Door.CanCollide = true 
            Door.Transparency = 0 
        else game.Workspace.Player["Left Arm"].Anchored = true -- Do I need this?
game.Workspace.Player["Right Arm"].Anchored = true -- Or this?
game.Workspace.Player["Left Leg"].Anchored = true -- Or this?
game.Workspace.Player["Right Leg"].Anchored = true -- Or this...
game.Workspace.Player.Head.Anchored = true -- Or this..
game.Workspace.Player.Torso.Anchored = true -- Because I kinda copied a poison script, which only works on the enemy... 
wait(1)
game.Workspace.Player.Health:Remove()
game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health -0.1
wait(1)
game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health -0.1
wait(1)
game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health -0.1
wait(1)
game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health -0.1 -- This goes on for along time until the wielder dies... 

Oh and where do I put the script in the sword...

THX!

Answer this question