PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Oct 01 2018, 3:00 AM PST

This code sample makes a character turn everything they touch into gold. Paste into a Script within StarterCharacterScripts.

local character = script.Parent

local function turnToGold(part)
	part.BrickColor = BrickColor.new("Daisy orange")
	part.Reflectance = .2
	part.Transparency = 0
	part.Material = Enum.Material.SmoothPlastic
end

local function onCharacterTouched(part)
	if not part.Parent:FindFirstChildOfClass("Humanoid") and part:GetMass() < 50 then
		turnToGold(part)
	end
end

for _, child in pairs(character:GetChildren()) do
	if child:IsA("BasePart") then
		child.Touched:Connect(onCharacterTouched)
	end
end