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

How do I separate this clothing giver script?

Asked by 7 years ago

I want to make it so I have two separate models, one with a script that performs the shirt portion and one that performs the pants portion. This script both gives the clothing if it's not currently being worn, and then gives back the original shirt/pants once clicked if it is being worn.

function onClicked(Playerz)

Player = Playerz.Character

if Player.Shirt.ShirtTemplate == "http://www.roblox.com/asset/?id=400434535" then

for _, child in pairs(script.Parent:GetChildren()) do
    if child.ClassName == 'StringValue' then

if child.Name == Player.Name.."Shirt" then
Player.Shirt.ShirtTemplate = child.Value
child:Destroy()
else if child.Name == Player.Name.."Pants" then
Player.Pants.PantsTemplate = child.Value
child:Destroy()
end
end


else
    end
end


else if Player.Shirt.ShirtTemplate == "http://www.roblox.com/asset/?id=200058009" then
--Other--
else if Player.Shirt.ShirtTemplate == "http://www.roblox.com/asset/?id=225769851" then
--Other--
else



local PS = Instance.new("StringValue")
PS.Name = Player.Name.."Shirt"
PS.Value = Player.Shirt.ShirtTemplate
PS.Parent = script.Parent

local PP = Instance.new("StringValue")
PP.Name = Player.Name.."Pants"
PP.Value = Player.Pants.PantsTemplate
PP.Parent = script.Parent

Player.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=400434535"
Player.Pants.PantsTemplate = "http://www.roblox.com/asset/?id=400435078"


end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Answer this question