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

Character respawns when it isn't supposed to?

Asked by
funyun 958 Moderation Voter
9 years ago

I tried making a hopperbin that takes control of [almost] anything that has a humanoid in it. Works the way it should in studio, but it respawns my character in the actual game, which it shouldn't. Could someone please figure this out?

player = game.Players.LocalPlayer
repeat wait() until player.Character
bin = script.Parent

function assumeControl(character)
    local cframe = character.Torso.CFrame
    character.Torso.CFrame = CFrame.new(cframe.x, cframe.y+(1/10^3), cframe.x)

    --Unanchoring
    for _, v in pairs(character:GetChildren()) do
        if v:IsA("BasePart") and v.Anchored then v.Anchored = false
        elseif v:IsA("Hat") and v.Handle.Anchored then v.Handle.Anchored = false
        elseif v:IsA("Tool") then
            for _, v2 in pairs(v:GetChildren()) do
                if v:IsA("BasePart") and v.Anchored then v.Anchored = false end
            end
        end

    player.Character = character
    workspace.CurrentCamera.CameraSubject = character.Humanoid
    end
end

function onButton1Down(mouse)
    local mt = mouse.Target
    if mt and mt.Parent:FindFirstChild("Humanoid") then
        assumeControl(mt.Parent)

    elseif mt and mt.Parent:IsA("Hat") then
    local x = mt
    repeat x = x.Parent until x.Parent == workspace
    local human = x:FindFirstChild("Humanoid", true)
    if human then assumeControl(human.Parent) end

    end
end

function onSelected(mouse)
    mouse.Button1Down:connect(function()onButton1Down(mouse) end)
end

bin.Selected:connect(onSelected)

1 answer

Log in to vote
2
Answered by 9 years ago

Set the AutoRespawn to off (Located under Players as a Property). This will allow for you to not be respawned, all you need to do now is make a system to automatically respawn people.

Ad

Answer this question