Issue with shirt giver

Hello, I have a issue with a shirt giver script. If you could help me out that would be great!

local debounce = false

function getPlayer(humanoid) 
local players = game.Players:children() 
for i = 1, #players do 
if players[i].Character.Humanoid == humanoid then return players[i] end 
end 
return nil 
end 

function onTouch(part) 

local human = part.Parent:findFirstChild("Humanoid") 
if (human ~= nil) and debounce == false then

debounce = true

local player = getPlayer(human) 

if (player == nil) then return end 

script.Parent:clone().Parent = player.Character

wait(2)
debounce = false
end
end

local player = game.Players:GetPlayerFromCharacter(human.Parent)

2 Likes

The script still does not work… I do not know why.

The script you provided isn’t a shirt giver, I’ve converted it into a shirt & pants giver.

local players = game:GetService("Players")

local part = script.Parent

local debounce = false

function onTouched(hit)
	if debounce then return end
	local hitModel = hit:FindFirstAncestorOfClass("Model")
	if hitModel then
		local hitPlayer = players:GetPlayerFromCharacter(hitModel)
		if hitPlayer then
			debounce = true
			local hitShirt = hitModel:FindFirstChildOfClass("Shirt") or Instance.new("Shirt")
			local hitPants = hitModel:FindFirstChildOfClass("Pants") or Instance.new("Pants")
			hitShirt.Parent = hitShirt.Parent or hitModel
			hitPants.Parent = hitPants.Parent or hitModel
			hitShirt.ShirtTemplate = "rbxassetid://3670737337"
			hitPants.PantsTemplate = "rbxassetid://23571256"
			task.wait(1)
			debounce = false
		end
	end
end

part.Touched:Connect(onTouched)

This is a server script placed inside the part(s).

1 Like