A little coding practice for myself, I’m making a realistic clothes hanger!!
How it works:
A hanger tool is given to the player, the player may dress themselves with the provided clothing shown on the hanger.
Player may change their clothing with the hanger, and put their shirt onto the hanger in exchange. If the hanger doesn’t have anything, the player is able to put their shirt onto the hanger, and vice versa.
Problem:
The script some how does not recognize the change of the hanger’s clothes or the player’s. It skips the if statements and goes straight to clothing swap.
Here is my function code:
local function Clicked(player)
local character = player.Character
if character then
print(character.Name .. " found with script!")
local playerShirt = character.Shirt
if playerShirt then
print("Player has a shirt!")
local clothing = model.Shirt
if clothing then
print("Model also has a shirt!")
local modelShirtTemplate = clothing.ShirtTemplate
local playerShirtTemplate = playerShirt.ShirtTemplate
if modelShirtTemplate and playerShirtTemplate then
local modelShirtTemplate = clothing.ShirtTemplate
clothing.ShirtTemplate = playerShirt.ShirtTemplate
playerShirt.ShirtTemplate = modelShirtTemplate
print("Shirts exchanged!")
else
print("ShirtTemplate not found on one of the shirts!😱😱")
end
else
print("Model does not have a shirt, hanging player's shirt on!")
playerShirt.Parent = model
end
else
print("Player does not have a shirt, taking from the hanger if available!")
local wear = model.Shirt
if wear then
wear.Parent = character
print("Player wore the shirt!")
end
end
end
end