Making Gui button to remove shirt

I wanna make a text button that removes your characters shirt when clicked. I dont see why it wont work? I know for a fact the local char is referenced correct so what is the issue?

local char = script.Parent.Parent.Parent.Parent.Parent.Parent.Character

script.Parent.MouseButton1Down:Connect(function()
	char.Shirt:Destroy()
end)

is that script in a localscript? only localscripts can detect if a GUI button has been pressed. if it is in a localscript you can do something like this

local plr = game.Players.LocalPlayer 
local char = plr.Character or plr.CharacterAdded:Wait() -- gets the local players character
script.Parent.MouseButton1Down:Connect(function()
	local shirt = char:FindFirstAncestorWhichIsA("Shirt") -- finds to see if the shirt exists
	if shirt then
		shirt:Destroy() -- will only destroy the shirt on the players screen, no one elses
	end
end)
3 Likes

If you want to destroy the shirt only for the one who pressed the button:

LocalScript:
(You need WaitForChild)

local char = game.Players.LocalPlayer

script.Parent.MouseButton1Down:Connect(function()
char:WaitForChild(Shirt):Destroy()
end)

If you want to destroy the shirt so everyone sees:

LocalScript:
local char = game.Players.LocalPlayer.Character

script.Parent:MouseButton1Down:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(player, char)

end)

Script:

game.ReplicatedStorage.RemoteEvent:OnServerEvent:Connect(function(player, char)
char:WaitForChild(“Shirt”):Destroy()
end)

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.