Still have questions? Join our Discord server and get real time help.
1

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


2
Edited 1 year ago

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


1
hellmatic 1517
2 years ago
Edited 2 years ago
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)


1
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

0
random() is deprecated, I don't know if you know that. DeceptiveCaster 3043 — 2y
0
it still work so watever RodrigatorOP 172 — 2y
0
xD Audiimo 105 — 2y
0
"it still work so watever" Eventually, it may be removed so uhm.. Yeah. xAtom_ik 575 — 2y