Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problem with uniform equipper?

So basically, I spent a good lot of time making this GUI for a guy, runs smoothly in Solo test but when I apply it to multiplayer it doesn't work! I am really confused here, does anybody see a problem?
.

script.Parent.MouseButton1Down:connect(function()
playername = script.Parent.Parent.Parent.Parent.Name
player = Workspace:FindFirstChild(""..playername.."")
if player ~= nil then
  player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=160490493"
  player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=160490464"
end
end)

2 answers

✓ Accepted answer

I'm guessing it's not a LocalScript which is required when using GUIs. Make it a LocalScript. An easier way of getting the character is by using the Character property from Player. player.Character

-- LocalScript
local player = game:GetService("Players").LocalPlayer -- Gets the player, only works in LocalScripts.
repeat wait() until player.Character -- Will loop until it gets the players Character.

script.Parent.MouseButton1Down:connect(function() -- Makes the event.
	local pants = player.Character:FindFirstChild("Pants")
	local shirt = player.Character:FindFirstChild("Shirt")
	if pants and shirt then -- If it finds the pants and shirt
		pants.PantsTemplate = "http://www.roblox.com/asset/?id=160490493"
		shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=160490464"
	end
end)

If your friend uses FilteringEnabled then this won't work, you'd have to learn to use these: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial

1 comment

0

Thanks!

The only thing that could be wrong is that it cannot find a 'Pants' or 'Shirt' Instance in the character model.

This discussion is preserved as it was. New answers, comments, and votes are closed.