I want to make a suit giver that returns the player to their normal avatar once they finish using the suit.
My current issue is that it doesn’t seem to run the “if” statement after taking out the suit.
I have attempted to re-script and put print statements in to check where the script is getting. When “SuitTaken” is true (suit is taken) then it connects the function but does not enter the “if” statement (where the code to remove the suit is).
Video:
Code:
local pantsId = script.Parent.Parent.Coathanger.Pants.PantsTemplate
local shirtId = script.Parent.Parent.Coathanger.Shirt.ShirtTemplate
local cPart = script.Parent
local cDetector = script.Parent.ProximityPrompt
local PlayerShirtID = "rbxassetid://0"
local PlayerPantsID = "rbxassetid://0"
local function Giver(player)
if script.Parent.SuitTaken.Value == false then
print("entered if statement")
local foundShirt = player.Character:FindFirstChild("Shirt")
if not foundShirt then
local newShirt = Instance.new("Shirt", player.Character)
newShirt.Name = "Shirt"
elseif foundShirt then
PlayerShirtID = player.Character.Shirt.ShirtTemplate
player.Character.Shirt:Remove()
local newShirt = Instance.new("Shirt", player.Character)
newShirt.Name = "Shirt"
script.Parent.SuitTaken.Value = true
local foundPants = player.Character:FindFirstChild("Pants")
if not foundPants then
local newPants = Instance.new("Pants", player.Character)
newPants.Name = "Pants"
elseif foundPants then
PlayerPantsID = player.Character.Pants.PantsTemplate
player.Character.Pants:Remove()
local newPants = Instance.new("Pants", player.Character)
newPants.Name = "Pants"
end
player.Character.Shirt.ShirtTemplate = shirtId
player.Character.Pants.PantsTemplate = pantsId
print(PlayerShirtID)
print(PlayerPantsID)
elseif script.Parent.SuitTaken.Value == true then
print("executing p2")
player.Character.Shirt:Remove()
local newShirt = Instance.new("Shirt", player.Character)
newShirt.Name = "Shirt"
player.Character.Shirt.ShirtTemplate = PlayerShirtID
player.Character.Pants:Remove()
local newPants = Instance.new("Pants", player.Character)
newPants.Name = "Pants"
player.Character.Pants.PantsTemplate = PlayerPantsID
script.Parent.SuitTaken.Value = false
print(PlayerShirtID)
print(PlayerPantsID)
print(script.Parent.SuitTaken.Value)
end
print("exited if statement")
end
end
cDetector.Triggered:Connect(Giver)
Output:
14:10:46.157 :: Adonis :: Loading Version: 259 Complete; Required by Loader version: 259 - Server
14:11:16.004 :: Adonis :: Changed lenovo17101s team to PTIA - Server
14:12:14.490 Video recording started - Studio
14:12:16.009 entered if statement - Server - Main:13
14:12:16.010 http://www.roblox.com/asset/?id=14190975975 - Server - Main:48
14:12:16.010 http://www.roblox.com/asset/?id=398633811 - Server - Main:49
14:12:16.010 exited if statement - Server - Main:73
14:12:34.394 Video recording stopped - Studio
14:12:41.137 :: Adonis :: Beginning Adonis cleanup & shutdown process... - Server
14:12:41.138 :: Adonis :: Unloading complete - Server
14:12:41.094 Disconnect from ::ffff:127.0.0.1|64726 - Studio
Any help would be greatly appreciated!