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

How do you make a model's transparency change when dragging it?

So far, I have this script. It clones a Model called 'Mini1' from the ReplicatedStorage. It does place down the model but the only problem it has is the Transparency when placing down. Not a single brick from the model becomes see through. In fact, it's invisible. I can't be able to fix this after several tries. Can someone help?

Here is the code:

a = script.Parent

function checkPressed(btn)
	a.MouseButton1Down:wait() 
	mouse = game.Players.LocalPlayer:GetMouse()
	clone = game.ReplicatedStorage.Mini1:Clone()
	wait()
	clone:GetChildren().Transparency = 0.5
	mouse.TargetFilter = clone
	dragging = true
	wait()
	while dragging do --set position until...
		wait()
		clone:MoveTo(Vector3.new(mouse.Hit.p.X, mouse.Hit.p.Y + (clone:GetExtentsSize().Y / 2), mouse.Hit.p.Z))
		wait()
		mouse.Button1Down:connect(--mouse down
		function() 
			dragging = false
			clone.Parent = workspace
			clone:GetChildren().Transparency = 0
			drg = true
			while drg do
				wait()
				mouse.Button1Up:connect(function()
					mouse.TargetFilter = nil
					drg = false
				end
				)
			end
		end
		)
	end
end
spawn(checkPressed())

I also get the error '11:53:33.494 - Spawn function requires 1 argument' in the last line

1 answer

First off, change the line

spawn(checkPressed())

to

spawn(checkPressed)

Then change

clone:GetChildren().Transparency = 0.5

to

for i, v in pairs(clone:GetChildren()) do
	if v:IsA("BasePart") or v:IsA("UnionOperation") then
		v.Transparency = 0.5
	end
end

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