This is a server script not a local one. Is that the issue?
Yes. TextBox focus needs to be on the client, or a local script. According to the FocusLost docs
Click Detector script:
local clickfinder = script.Parent
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 = script.Parent.Parent
Player.PlayerGui.GiverGui.Enabled = true
end
end)
GUI script (make sure its a LocalScript)
local SetPants = script.Parent
local Prefix = "rbxassetid://"
SetPants.FocusLost:Connect(function(enterpressed)
if enterpressed then
print("Setting dummy pants ID")
game.Players.LocalPlayer.Mannequin.Value:FindFirstChild("Pants").PantsTemplate = Prefix..SetPants.Text
end
end)
I edited the mannequin code. Try that.
The print worked this time and there was no error, but nothing happened. : (
edit: I noticed it sets the ID, but it just doesn’t show it. I saw a post on this once but I can’t find it.
Edit 2: I found the post, but it doesn’t work on local scripts.
poke (if roblox forums boost posts by replies)
I tried to make it send the code to a value inside the dummy then have a script that checks when the value updates. the script was supposed to load the id to the game and give it to the dummy but it didn’t work.
Not 100% sure since I haven’t messed with assets too much but I believe this must be set server side for it to load. Try sending it through a remote and set it through the server.
Let me know if it works!
I am super new to coding what do you mean by that? sorry : (
Read all about it here! Let me know if it makes sense after a read.
Now that I think about it this one sounds more beginner friendly. Here you go.
I was about to say i physically couldnt read the first one
I read it and I thought I got it? I tried it out an got an error
these were the events I made (ignore the shirt one im doing that one after I figure out the pants one!!)
script in the dummy:
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)
-- Get reference to remote event instance
local function changePants(id)
mannequin.Pants.PantsTemplate = id
end
-- Connect function to event
remoteEventPants.OnServerEvent:Connect(changePants)
script in the textbox:
local SetPants = script.Parent
local Prefix = "rbxassetid://"
local Marketplace = game:GetService("MarketplaceService")
local MarketPlaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEventPants = ReplicatedStorage:FindFirstChild("PantsMannequinChanged")
SetPants.FocusLost:Connect(function(enterpressed)
if enterpressed then
print("Setting dummy pants ID")
local IsClothingValid = pcall(Marketplace.GetProductInfo, Marketplace, SetPants.Text)
if IsClothingValid then
print("Valid Id. Checking if it is pants....")
local ProductInfo = MarketPlaceService:GetProductInfo(tonumber(SetPants.Text))
if ProductInfo.AssetTypeId == 12 then
print("Success!")
remoteEventPants:FireServer(Prefix..SetPants.Text)
else
print("Please use a pants ID.")
end
else
print("Invalid ID.")
end
end
end)
the error:
I had this exact same problem in my game, for some reason scripts cant change pants and shirts of rigs and you have to use insert service.
heres the code I used I found it in my game
local model = game:GetService("InsertService"):LoadAsset(id)
local pants = model:WaitForChild("Pants")
local clone = pants:Clone()
clone.Parent = -- your model
model:Destroy()
has to be done serverside btw
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