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

executing a script/command on a person?

Asked by
Vividex 162
7 years ago
Edited 7 years ago
local TARGET = script.Parent.PlayerName.Text
local plr = game.Players:FindFirstChild(TARGET)
local lpChar=game.Players.LocalPlayer.Character.Torso

if script.Parent.Command.Text == "bring" then
    lpChar.Anchored = true
    local w = Instance.new("Weld", lpChar)
    w.Part0 = lpChar
    w.Part1 = plr.Character.Torso
    w.C0 = lpChar.CFrame
    w.C1 = lpChar.CFrame
    wait(.1)
    w:Destroy()
    lpChar.Anchored = false
end

if script.Parent.Command.Text == "kill" then
    for i,v in pairs (game.Players.LocalPlayer.Character:GetChildren()) do
     if v.ClassName == 'Part' then
      if v.Name ~= 'Head' then
       v.Anchored = true
      end
     end
    end
    local w = Instance.new("Weld", lpChar)
    w.Part0 = lpChar
    w.Part1 = plr.Character.Torso
    w.C0 = lpChar.CFrame
    w.C1 = lpChar.CFrame * CFrame.new(0, -10000, 0)
    wait(0.1)
    w:Destroy()
    for i,v in pairs (game.Players.LocalPlayer.Character:GetChildren()) do
     if v.ClassName == 'Part' then
      if v.Name ~= 'Head' then
      v.Anchored = false
      end
     end
    end
end

Here's a photo of the GUI setup

I'm trying to make it so if you type a player's name in the "PlayerName" textbox, it'll run the kill script or bring script on that player if you type "kill" or "bring" in the Command textbox

1 answer

Log in to vote
0
Answered by 7 years ago

ok i do not know if this'll work but i only "fixed" the kill command... however you need to put a space like: kill Player1

local TARGET = script.Parent.PlayerName.Text
local plr = game.Players:FindFirstChild(TARGET)
local lpChar=game.Players.LocalPlayer.Character.Torso

if script.Parent.Command.Text == "bring " then
    lpChar.Anchored = true
    local w = Instance.new("Weld", lpChar)
    w.Part0 = lpChar
    w.Part1 = plr.Character.Torso
    w.C0 = lpChar.CFrame
    w.C1 = lpChar.CFrame
    wait(.1)
    w:Destroy()
    lpChar.Anchored = false
end

if script.Parent.Command.Text:sub(1,5) == "kill " then
    local filler = script.Parent.Command.Text:sub(6)
    for _,v in ipairs(game.Players:GetChildren()) do
        if v.Name == filler then
            for i,v in pairs (filler:GetChildren()) do
     if v.ClassName == 'Part' then
      if v.Name ~= 'Head' then
       v.Anchored = true
      end
     end
    end
    local w = Instance.new("Weld", lpChar)
    w.Part0 = lpChar
    w.Part1 = plr.Character.Torso
    w.C0 = lpChar.CFrame
    w.C1 = lpChar.CFrame * CFrame.new(0, -10000, 0)
    wait(0.1)
    w:Destroy()
    for i,v in pairs (game.Players.LocalPlayer.Character:GetChildren()) do
     if v.ClassName == 'Part' then
      if v.Name ~= 'Head' then
      v.Anchored = false
      end
     end
    end
        end
    end
end
Ad

Answer this question