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

How to change character without killing?

Asked by
JJ_B 250 Moderation Voter
8 years ago

I made a tool that transforms your character into the player's character that you clicked. It uses a raycast beam to do this. But I want to know how I would perform the character change without killing the player who changes. Here is the script;

local tool = script.Parent
local player = game:GetService("Players").LocalPlayer

tool.Equipped:connect(function(mouse)

    mouse.Button1Down:connect(function()
        local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
        local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)

        local beam = Instance.new("Part", workspace)
        beam.BrickColor = BrickColor.new("Crimson")
        beam.FormFactor = "Custom"
        beam.Material = "Neon"
        beam.Transparency = 1
        beam.Anchored = true
        beam.Locked = true
        beam.CanCollide = false

        local distance = (tool.Handle.CFrame.p - position).magnitude
        beam.Size = Vector3.new(0.2, 0.2, distance)
        beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)

        game:GetService("Debris"):AddItem(beam, 0.1)

        if part then
            local humanoid = part.Parent:FindFirstChild("Humanoid")

            if not humanoid then
                humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
            end

            if humanoid then
                local c = game.Players:GetPlayerFromCharacter(humanoid.Parent)
            game.Players.LocalPlayer.CharacterAppearance  = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=".. c.UserId
            game.Players.LocalPlayer.Character:BreakJoints()
            end
        end
    end)
end)

Please help!

0
I would not use the CharacterAppearance I would instead get the player's model in workspace and clone all its CharacterMeshes, hats, shirts, pants etc and put them in your character model DevArk 50 — 8y

Answer this question