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

how do i change a player's character model mid-game?

Asked by 5 years ago
Edited by minikitkat 5 years ago

take a look at this video here, this showcases the outcome of my scripts, and, how it's a problem. it also details some other stuff so thats important

here's the important parts of the script:

character_change (located in ServerScriptService) - serverscript

local characterpart = workspace:FindFirstChild("characterpart")
local basehumanoid = game.StarterPlayer.StarterHumanoid
local startercharacterscripts = game.StarterPlayer.StarterCharacterScripts
local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local cameraevent = Instance.new("RemoteEvent", replicatedstorage)
cameraevent.Name = "cameraevent"
local touchbool = false

local function onTouch(otherpart)
    if otherpart.Parent:FindFirstChild("Humanoid") ~= nil and touchbool == false then
        local players = game.Players:GetPlayers()
        local playername = otherpart.Parent.Name
        local player = game.Players:FindFirstChild(playername)
        touchbool = true

        local newchara = serverstorage:FindFirstChild("Chara"):Clone()
        newchara.Name = player.Name
        newchara.Parent = workspace
        newchara:MoveTo(game.Players:FindFirstChild(playername).Character:FindFirstChild("HumanoidRootPart").Position)
        local newhumanoid = basehumanoid:Clone()
        newhumanoid.Parent = newchara
        newhumanoid.Name = "Humanoid"
        local newscripts = startercharacterscripts:GetChildren()
        for i = 1, #newscripts do
            local f = newscripts[i]:Clone()
            f.Parent = newchara
        end
        local oldchara = player.Character
        player.Character = nil
        print(oldchara)
        player.Character = newchara

        cameraevent:FireClient(player, newchara)
        --cameraevent:FireClient(player)
        wait(1)
        touchbool = false
    end
end
characterpart.Touched:Connect(onTouch)

controls_overworld (located in PlayerScripts) - localscript

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local cameraevent = ReplicatedStorage:WaitForChild("cameraevent")

local function camerafocus(charactermodel)
    print(charactermodel)
    local camera = workspace.CurrentCamera
    camera.CameraSubject = player.Character:FindFirstChild("Humanoid")
    --wait(1.5)
    print(player.Character)
end
cameraevent.OnClientEvent:Connect(camerafocus)
0
Please watch your language. This is supposed to be a child friendly site. User#21908 42 — 5y
0
oh, sorry, i didn't think 'hell' would've been interpreted as non-child friendly SuperKirbylover 107 — 5y

Answer this question