Custom Dummy Loader

Hi everyone, i’m trying to create a random dummy loader.
Better explanation: When a player enters in the game 1 of 5 dummys must load his skin and model, so you can use it for personal statue or something similiar that have a pose.

The problem is, i’m using this free script found on the toolbox that works fine, i’ve modified it adding something but when a character is loaded it loads only his skin/textures so all R15 character become R6 and if using a R15 model arms, legs and other body parts become basic R15 without foot or hand for example, there are the scripts i’m using.

game.Players.PlayerAdded:Connect(function(player)
	     print(player.UserId)
	wait(1)
	local num = math.random(1,5)
	if num == 1 then print("1 is ", player.UserId)
		if game.Workspace.Dummy1.Value.Value ~= 0 then
			 player()
			 print("Sorry but this Dummy skin has been taken by ", game.Workspace.Dummy1.Value.Value )
			 end
		game.Workspace.Dummy1.Value.Value = player.UserId

	elseif num == 2 then print("2 is ", player.UserId)
		if game.Workspace.Dummy2.Value.Value ~= 0 then
			 player()
			 print("Sorry but this Dummy skin has been taken by ", game.Workspace.Dummy1.Value.Value )
			 end
		game.Workspace.Dummy2.Value.Value = player.UserId

	elseif num == 3 then print("3 is ", player.UserId)
		if game.Workspace.Dummy3.Value.Value ~= 0 then
			 player()
			 print("Sorry but this Dummy skin has been taken by ", game.Workspace.Dummy1.Value.Value )
			 end
		game.Workspace.Dummy3.Value.Value = player.UserId
	
	elseif num == 4 then print("4 is ", player.UserId)
		if game.Workspace.Dummy4.Value.Value ~= 0 then
			 player()
			 print("Sorry but this Dummy skin has been taken by ", game.Workspace.Dummy1.Value.Value )
			 end
		game.Workspace.Dummy4.Value.Value = player.UserId
		
	elseif num == 5 then print("5 is ", player.UserId)
		if game.Workspace.Dummy5.Value.Value ~= 0 then
			 player()
			 print("Sorry but this Dummy skin has been taken by ", game.Workspace.Dummy1.Value.Value )
			 end
		game.Workspace.Dummy5.Value.Value = player.UserId
	end
end)

This script uses a random number between 1 and 5 and associate the number to a dummy with corrispettive name using a value inside the model, the value wil be the player ID and another script will load this ID loading the player’s skin.
Also, when loading the dummy it spawns both R6 and R15 pieces in a point of the map, hope there is a way to fix this

second sript
NOTE this must be put inside evey dummy and also the value

wait(5)
if script.Parent.Value.Value == 0 then
	print("No Skin Found")
	script.Parent:Destroy() end

local id = script.Parent.Value.Value
local Models = game.Players:GetCharacterAppearanceAsync(id)
Models.Parent = script.Parent
wait(.2)
for i,v in pairs(Models:GetChildren()) do
	print(v.Name)
	v.Parent = script.Parent
	wait(.2)
end

try adding 5 dummy’s that you have out of view in the map, and name them all things like Dummy1 then try this code

local Players = game:GetService("Players")
 
if Players.PlayerAdded then
local num = math.random (1,5)
if num == 1 then
game.Workspace.Dummy1.Name = StarterHumanoid

then repeat for other dummys.

1 Like

That’s a bad idea. Speaking from experience, you should avoid this.


I think before we continue, you should shorten your code. The golden rule of programming is to shorten code to functions and reduce redundancy. You have repitive code that could just be written once and called many times as functions.

Once you shorten your code, come back :slight_smile:

1 Like