I don't know how to update the appearance of the dummy using the player character

Well i don’t have exactly a script that does something like that, but i tested deleting the shirts in workspace when i run the game in roblox studio, the script detects that and the funciton runs.

1 Like

maybe is wrong if i do it like that but im testing right now so i dont need to edit scripts if i finish this.


-- Local Script
local function characterChanged(object)
	local character = player.Character
	if character then
			detectChangedEvent:FireServer(object)
	end
end

-- Conectar la función a los eventos adecuados
player.CharacterAdded:Connect(function()
	
end)

player.Character.ChildAdded:Connect(function(ObjectAdded)
	characterChanged(ObjectAdded)
end)

player.Character.ChildRemoved:Connect(function(ObjectRemoved)
	characterChanged(ObjectRemoved)
end)

and

-- Server
local function updateDummy(player, object)
	local dummy = dummies[player.UserId]
	
	if dummy then
        if object:IsA("Shirt") then
		    dummy.Shirt.Id = object.Id
        end
	end
end
detectChangedEvent.OnServerEvent:Connect(updateDummy)

Honestly, some of your code doesn’t make sense, but I made some changes, so basically when a child is added to the character (detected from a local script), then it fires a remote event to the server with the child, checks if the child is a shirt, if it is then it uses the ID of that child and applies it to the dummy’s shirt.

This means that, when a player wears a shirt (ChildAdded) or removes a shirt (ChildRemoved), it applies the shirt to the dummy.

im going to test it, thanks, im going to say if it works.

detectChangedEvent.OnServerEvent:Connect(player, object)

is incorrect, you need to put the function, but i think that we are close to fix all of this problem

and if i put the function in the OnServerEvent, it doesn’t gives errors, but the shirt doesn’t apply

Oops, yeah just replace it with a function, that was a silly mistake.

Alright, then do print(object.Id). Let’s see what it shows on the output.

local function updateDummy(player, object)
	local dummy = dummies[player.UserId]

	if dummy then
		if object:IsA("Shirt") then
			print(object.Id)
		end
	end
end
detectChangedEvent.OnServerEvent:Connect(updateDummy)

it doesn’t print if the script is like that

but if remove the lines

if object:IsA(“Shirt”) then
end

and i leave the print it gives a error

Id is not a valid member of Accessory “Workspace.ZyntaxStar.Black Vest”

and the same error with everything inside the character

That is literally what I’m saying, your code doesn’t make sense… childadded events detect when a new child is parented to a character, that child could be an accessory or a tool. When you reset your character, it will detect all the new accessories that will be added to the character.


“Workspace.ZyntaxStar.Black Vest” -- this is an accessory

You need to add code to make it so that a player can wear a shirt, rather than doing it manually in studio via workspace.

Ok i understand i think… so, whats next? i need to do new code so i can detect the shirts added and accesorys and other things ? because i want to detect it when i join to the game so the dummy gets the accessorys and shirts detected its very confusing to explain but i think that you understand.

I 100% do understand what you are saying but you need to use your own game logic to check when a player wears a shirt, for example, is it through a textbutton? proximity prompt? It’s all on you.

It’s when the player joins to the game, the script gets all the accessories and shirts, and passes them to the dummy to be cloned to the dummy, after that I don’t know how to detect if a shirt is removed or added to the player for the dummy to clone it.

I’ll just create a place and I’ll give you the file for it so that you can access it.

I’ll create 2 objects where one of them, you can click to wear a shirt and one of them will remove the shirt of the player’s character.

When I wear a shirt, I’ll also ensure that it also applies to the dummy.

I’ll come back soon.

Oh, Thank you so much, I would really appreciate it if you do that.

1 Like

just clone the player … and then replace dummy

Something like this …

local function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        local dummy = game.Workspace:WaitForChild("Dummy")
        local clone = hit.Parent:Clone()
        clone.Parent = workspace
        dummy:Destroy()
    end
end

game.Workspace.Dummy.Touched:Connect(onTouched)

im going to try it thanks so much!

Actually, don’t try that one, try this:

Updated ShirtScript.rbxl (77.1 KB)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.