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

Why is the part spawning in the player's body?

Asked by 5 years ago

I'm making an obby game where a part is welded to a player's body. However, I want the part to be above the player, but when the code runs, The part gets put in the player. Why does this happen and how do i fix this? The script is in ServerScriptService. The code is

game.Players.PlayerAdded:Connect(function(plr)
    local part = game.ServerStorage.Part
    plr.CharacterAdded:connect(function(char)
        local clonedPart = part:Clone()
        clonedPart.Parent = char
        local weld = Instance.new("Weld", clonedPart)
        weld.Part0 = char.Torso
        weld.Part1 = weld.Parent
        clonedPart.Anchored = false
        clonedPart.CFrame = char.Torso.CFrame + Vector3.new(0,20,0)
    end)
end)
0
The char...Because Character is the player... MaxDev_BE 55 — 5y
0
You need to set C0 and/or C1 to change the offset between the 2 objects. Example is generic teleporting. When you teleport someone, you set their Torso's CFrame. Does that make only their Torso move? Naw, it makes the whole welded body move together as a unit. ScrewDeath 153 — 5y
0
The parent argument to Instance.new is deprecated, assign the parent in another line User#19524 175 — 5y
0
Incapaz ur not helping this guy. You're not even answering the question he askeddd SBlankthorn 329 — 5y
0
Try character.Head at line 07 shephali 3 — 5y

Answer this question