Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

transparency in part wont change when clicked?

Asked by 6 years ago

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

Log in to vote
2
Answered by 6 years ago
Edited 5 years 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

Ad
Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 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)

Log in to vote
1
Answered by 6 years ago
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 3761 — 6y
0
it still work so watever RodrigatorOP 172 — 6y
0
xD Audiimo 105 — 6y
0
"it still work so watever" Eventually, it may be removed so uhm.. Yeah. xAtom_ik 574 — 6y
Log in to vote
1
Answered by 6 years ago

thx u all guys im almost done with my model now

Answer this question