I made a tool, so when you click on a player, it can give them a shirt. When I click that other player, it gives myself that shirt, not the other player.
Local script
Tool = script.Parent
PMouse = game.Players.LocalPlayer:GetMouse()
Click = true
on = false
Tool.Equipped:connect(function()
on = true
end)
Tool.Unequipped:connect(function()
on = false
end)
Tool.Activated:connect(function()
if PMouse.Target.Parent:FindFirstChild("Humanoid") and on == true or PMouse.Target == nil and on == true then
local mouseHitPlr = game.Players:GetPlayerFromCharacter(PMouse.Target.Parent)
game.ReplicatedStorage.EquipShirt:FireServer(mouseHitPlr)
Click = false
end
end)
Server Script
local RS = game:WaitForChild("ReplicatedStorage")
local event = RS.EquipShirt
local ShirtID = "rbxassetid://676428254"
local function onEquipShirt(player)
local foundShirt = player.Character:FindFirstChild("Shirt")
if not foundShirt then -- if there is no shirt
print("No Shirt Found: "..player.Name)
local newShirt = Instance.new("Shirt",player.Character)
newShirt.Name = "Shirt"
else if foundShirt then -- if there is a shirt
print("Existing Shirt Found: Shirt ID has changed for "..player.Name)
player.Character.Shirt:remove()
local newShirt = Instance.new("Shirt",player.Character)
newShirt.Name = "Shirt"
end
end
player.Character.Shirt.ShirtTemplate = ShirtID
end
event.OnServerEvent:Connect(onEquipShirt)

1 comment
Change the ShirtTemplate of the shirt they are wearing.