I’m creating a function which will spawn a character at a point when called and remove one if pre existing. However, I have the issue that when I call it twice to two different places, they spawn in the same place.
local function ReplaceCharacter(Stand)
local RemoveChar = game.Workspace:FindFirstChild(Player.Name.." "..Stand.Name)
if RemoveChar then
RemoveChar:Destroy()
end
local CharFormatted = string.sub(CurrentOutfit, 3, #CurrentOutfit)
local CharToClone = CosmeticModels.OUTFIT:FindFirstChild(CharFormatted)
CharClone = CharToClone:Clone()
CharClone.Name = Char.Name.." "..Stand.Name.." "..CurrentOutfit.." Clone"
CharClone:PivotTo(Stand.CFrame)
CharClone.Parent = workspace
local NewAnim = Instance.new("Animation", CharClone)
NewAnim.AnimationId = Animations.Idle
local Idle = CharClone.Humanoid:LoadAnimation(NewAnim)
Idle:Play()
end
ReplaceCharacter(LockerStand)
ReplaceCharacter(LobbyStand)
CurrentOutfit is the name of the outfit I am trying to spawn. I look for it in replicated storage, and clone it, setting it’s CFrame to a variable I pass through; “Stand”
However, when I call this twice to two different places, they both spawn to where the first location was. Yes, it’s meant to be the same skin. Why would this be, and is there any way to fix this?
Thanks, Lukas