In my game, I want the player to have their legs switched for a mermaid tail when they are in water. To do so, I figured it would be best to attach the tail to the player (no collisions, invisible) when they join the game and change the transparency when I need to, instead of cloning it to them/removing it every time they enter or leave the water. (If you think there is a better approach than what I am working with, please let me know too)
The issue I am experiencing with my current approach is that when I try to clone the model from ServerStorage to the player, the model spawns far away from the player, instead of where I clone it and weld it to. The model still moves with the player, it is just offset by a lot. Here is my code:
local TailSource = game.ServerStorage.TakeTail
local function onCharacterAdded(character)
local TailModel = TailSource:Clone()
TailModel.PrimaryPart = TailModel.RootPart
TailModel.PrimaryPart.CFrame = character.LowerTorso.CFrame
TailModel.Parent = character.LowerTorso
local Weld = Instance.new("WeldConstraint")
Weld.Parent = character.LowerTorso
Weld.Part0 = TailModel.PrimaryPart
Weld.Part1 = character.LowerTorso
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
game.Players.PlayerAdded:Connect(onPlayerAdded)
I cant seem to replicate the issue. The only time it fails for me is if I don’t put a short wait (1 second) in after the Clone(). Without that short wait the tail doesn’t clone in at all.
I had previously tried putting in a short wait, and the tail did clone successfully but was still offset, just by a smaller amount. If you weren’t able to replicate the issue, I am wondering if it might be a problem with the model itself, and maybe its welding.
I did try offsetting the WorldPivotPosition() (I thought this might be it because you said it moved around with you but was offset by a mile) but I couldn’t emulate the same results. I tried collision, no-collision, anchored, un-anchored but I couldn’t make the thing not appear and follow me around, it was always there and at the right location. Try the WorldPviotPosition() thing, maybe there is an offset in your model that is creating some mad, unusual effect that I can’t replicate without your model. I don’t know, I tried to emulate the same effect with a generic model from the Toolbox but I couldn’t. The only thing I noticed was unless I put a wait in just after the Clone() there was no model cloned in at all no matter how long I waited for it Clone() in, only when the wait was there did it make a difference. Go figure!
So I think I am getting a bit closer to the issue. That offset I mentioned, when there is a short wait, is actually just the workspace position of the model. So the model is cloning, welding to the player, but the CFrame reassigning must not be working, due to the model cloning to its original position, but I am not getting any errors from the script. I tested it with two parts I welded together then grouped, and the issue was the same. They cloned in to their original position and welded, but weren’t effected by the CFrame changing.