local TS = game:GetService("TweenService")
script.Sound:Play()
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, id)
local character = game.Players:CreateHumanoidModelFromUserId(id)
character:PivotTo(workspace.Parts.CharacterSpawn.CFrame)
character.Parent = game.Workspace
task.wait(1)
print("1")
local tween = nil
for i, v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") then
tween = TS:Create(v, TweenInfo.new(0.5), {Position = workspace.Parts.CharacterGoal.Position})
tween:Play()
end
end
tween.Completed:Connect(function()
script.Sound.TimePosition = 0.5
script.Sound.Volume = 1
script.Sound:Play()
end)
end)
I’m trying to make a script where a local script fires a remote event that makes a model of the player’s character and tweens it from the CharacterSpawn part to the CharacterGoal part. When the script plays, nothing happens, but “1” is printed. There are no errors in the output. How do I fix this?
Instead of printing 1, try printing out the id. It may be an issue with the id not being valid. Also just to make sure: this IS in a server script right?
It’s a server script, and I did print the ID and username and they both worked. I checked workspace when it was loaded and it actually loaded the model, but the model had no parts, only accessories.
Could it be an issue with the tween? If you haven’t already, try commenting out the tween section and then going over to whereever you’re pivoting the model to. I’ve never used this method (CreateHumanoidModelFromUserId) so I’m not sure if you’re doing anything wrong there but it’s best to try debugging with other parts of the code.
I meant that it could be tweening incorrectly, it kind of looks like you’re just tweening all the descendants to the same spot? Correct me if I’m wrong
if that were the case then all the descendants would be tweened to the same spot and make the character look weird, which is a different issue. i need to make sure the descendants actually appear in workspace
wait actually! have you tried printing the amount of descendants that are base parts in the model?
you can either print #character:GetDescendants() (there might be a :GetDescendantsOfClass() but im not sure) or you make a variable that increments by 1 every time it finds a basepart then print it after the for loop.
Also, going back to the tween, shouldn’t the tween.Completed part be in the for loop aswell?? If you place it after the for loop, it’s only going to check for one tween, unless that’s what you’re going for.