thank you!!! ill try this out : )
uh
i have no idea what this error means
try doing
:LoadAsset(tonumber(id))
wait are you using the prefix before the id i think thats the problem
just do the id
OH YEAH I AM OOPS HAHA djasjdjkasd
I got this error
same line as before
oh wait i see the problem when a remote event is triggered through client side the plyr is always the first argument (even if you didnt send it ) so your script think “id” is the player so do
local function changePants(plyr, id )
OMG THANK YOU SO MUCH IT WORKS NOW ADBJASDHASDHAJJDH
I feel so embarrassed and dumb rn but new problem
It only lets me change it once, and it applies the change to all mannequins. A friend pointed out the change to all mannequins issue was because of using only one event or smth but idk how to fix it!!
Yep! Now you have to add another argument: the mannequin to change. Should look something like
function changePants(plr, mannequin, id)
then remove the mannequin variable from above. Then what you want to do is just keep one of the server script (the one you changed) and move it over to ServerScriptService, that way you don’t have multiple connections running on the same remote event (very bad if you have tens of mannequins in your game).
what bt6k said is true but you also need to run a check to see if the mannequin already has pants/shirts for you could so something like
for _, child in pairs(mannequin:GetChildren()) do
if child:IsA("Pants") or child:IsA("Shirt") then
child:Destroy()
end
end
I have no idea how to do what youre saying. I only have one script thats in the mannequin and I dont know how I would move it to sss??? i dont know how to grab the specific mannequin that was clicked.
local clickfinder = script.Parent
local mannequin = script.Parent.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEventPants = ReplicatedStorage:FindFirstChild("PantsMannequinChanged")
clickfinder.MouseClick:Connect(function(Player)
print(Player.Name.." clicked me!")
if Player.PlayerGui.GiverGui.Enabled == false then
local Target = Player:FindFirstChild("Mannequin")
if not Target then
Target = Instance.new("ObjectValue")
Target.Name = "Mannequin"
Target.Parent = Player
end
Target.Value = mannequin
Player.PlayerGui.GiverGui.Enabled = true
end
end)
local function changePants(plyr, bmannequin, id)
for _, child in pairs(mannequin:GetChildren()) do
if child:IsA("Pants") then
child:Destroy()
end
end
local model = game:GetService("InsertService"):LoadAsset(tonumber(id))
local pants = model:WaitForChild("Pants")
local clone = pants:Clone()
clone.Parent = mannequin
model:Destroy()
end
remoteEventPants.OnServerEvent:Connect(changePants)
i really just dont understand what youre saying basically, im not smart enough
you need to communicate with the server through your local script what mannequin you are changing
edit : more specifically
local script
(yourremoteevent):FireServer(id, -- the mannequin that you want to change will go here)
server side
(yourremoteevent).OnServerEvent:Connect(function(plyr, id, mannequin)
-- code goes here
end)
the script that I sent earlier just checks if the mannequin is wearing pants/shirt and removes it so that a new one can be placed.