Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I change script which works by touching to works by clicking in GUI?

Hi, I have script with giving "T-shirt" or decal but it works only by touching, how can I turn it to works only by clicking in GUI?

This is this script

local brick = script.Parent
local decal = brick:findFirstChild("Decal")

function GetFace(hit)
	local humanoid = hit.Parent:findFirstChild("Humanoid")
	local torso = hit.Parent:findFirstChild("Torso")
	if torso ~= nil and humanoid ~= nil then
		local shirt = hit.Parent:findFirstChild("Shirt Graphic")
		if shirt ~= nil then
			shirt.Graphic = decal.Texture
		else
			local altshirt = torso:findFirstChild("roblox")
			if altshirt ~= nil then
				altshirt.Texture = decal.Texture
			else
				print("Torso found. Shirt not found. Assumed to be a robot.")
			end
		end
	else
		print("Not a valid person! T-Shirt cannot be changed!")
	end
end

brick.Touched:connect(GetFace)

1 answer

Here's something I just made, it's exactly what you asked for. Place this code in a Script, then place the Script in the part with the decal.

local Part = script.Parent
local Decal = Part:FindFirstChildOfClass("Decal")
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.MouseClick:Connect(function(Player)
	local Character = Player.Character
	for i,v in pairs(Character:GetDescendants()) do
		if v:IsA("ShirtGraphic") then
			v:Destroy()
		end
	end
	local ShirtGraphic = Instance.new("ShirtGraphic")
	ShirtGraphic.Graphic = Decal.Texture
	ShirtGraphic.Parent = Character
end)
ClickDetector.Parent = Part

1 comment

0

That's not that what I'm asking for

This discussion is preserved as it was. New answers, comments, and votes are closed.