Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with uniform equipper?

Asked by 9 years ago

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

Log in to vote
1
Answered by
SirNoobly 165
9 years ago

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

0
Thanks! UrsusLuciusBatiatus 15 — 9y
Ad
Log in to vote
-1
Answered by
KLGA 0
9 years ago

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

Answer this question