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

transparency in part wont change when clicked?

pls help me again i added a click to transparency change my part but it not working whats weird about it its theres no error output it just wont work idk why this is frustrating pls heelp

part = game.Workspace.skate
transparency = part.Transparency
clickdetector = part.ClickDetector

clickdetector.MouseClick:Connect(function()
	print("change transparency")
	if transparency >= 1 then transparency = 0 end
	transparency = transparency + .1
end)

while true do
    part.CFrame = part.CFrame*CFrame.new(1,0,0)
    part.BrickColor = BrickColor.random()
    print("debug")
end

4 answers

Let's see what I can debug here in your script.

  • Your while true do loop does not have a wait() in it, thus increasing the chance of the script crashing.

Here is the modified script:

part = game.Workspace.skate
local clickdetector = part.ClickDetector

clickdetector.MouseClick:Connect(function()
	print("change transparency")
	if part.Transparency >= 1 then
		part.Transparency = 0
	end
        part.Transparency = part.Transparency + 0.1
end)

while true do
    part.CFrame = part.CFrame*CFrame.new(Vector3.new(1,0,0))
    part.BrickColor = BrickColor.Random()
    print("debug")
    wait()
end

part = game.Workspace.skate
transparency = part.Transparency
clickdetector = part.ClickDetector

clickdetector.MouseClick:Connect(function()
    print("change transparency")
    if transparency > 0.9 then 
   	 transparency = 0
    end

    transparency = transparency + 0.1 -- If your trying to make the part fade, add this inside the loop (while true do)
end)

spawn(function() -- This is to make sure the loop doesn't interrupt the MouseClick function
	while true do
   	 part.CFrame = part.CFrame*CFrame.new(1,0,0)
  	  part.BrickColor = BrickColor.random()
   	 wait() -- ALWAYS add a wait() to a loop or your script will crash
    	print("debug")
	end
end)

part = game.Workspace.skate
clickdetector = part.ClickDetector

clickdetector.MouseClick:Connect(function()
    print("change transparency")
    if part.Transparency >= 1 then part.Transparency = 0 end
    part.Transparency = part.Transparency + .1
end)

while true do
    part.CFrame = part.CFrame*CFrame.new(1,0,0)
    part.BrickColor = BrickColor.random()
    print("debug")
	wait()
end

4 comments

0

random() is deprecated, I don't know if you know that.

0

it still work so watever

0

xD

0

"it still work so watever" Eventually, it may be removed so uhm.. Yeah.

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