Change character with proximity prompt issues

Basically I am practicing game development, and I’m trying to make a proximity prompt that changes the player’s character
Here is the script

local prompt = script.Parent
local characterName = "Morph"
local character = prompt.Parent:WaitForChild(characterName)
 
prompt.Triggered:Connect(function(obj)
    local plr = game.Players:GetPlayerFromCharacter(obj.Parent)
       
        local charClone = character:Clone()
        charClone.Name = plr.Name
        plr.Character = charClone
       
        local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso")
        local plrRoot = obj.Parent:FindFirstChild("HumanoidRootPart") or obj.Parent:FindFirstChild("Torso")
       
        if rootPart and plrRoot then
            rootPart.CFrame = plrRoot.CFrame
        end
       
        charClone.Parent = workspace
       
        wait(.5)
end)

Can anyone help me solve this issue?

local prompt = script.Parent
local characterName = "Morph"
local character = prompt.Parent:WaitForChild(characterName)
 
prompt.Triggered:Connect(function(plr)
        local charClone = character:Clone()
        charClone.Name = plr.Name
        plr.Character = charClone
       
        local rootPart = charClone:FindFirstChild("HumanoidRootPart") or charClone:FindFirstChild("Torso")
        local plrRoot = obj.Parent:FindFirstChild("HumanoidRootPart") or obj.Parent:FindFirstChild("Torso")
       
        if rootPart and plrRoot then
            rootPart.CFrame = plrRoot.CFrame
        end
       
        charClone.Parent = workspace
       
        wait(.5)
end)
proximityPrompt.Triggered:Connect(function(player)

The prompt is always triggered by player , not by character.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.