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 7 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

01part = game.Workspace.skate
02transparency = part.Transparency
03clickdetector = part.ClickDetector
04 
05clickdetector.MouseClick:Connect(function()
06    print("change transparency")
07    if transparency >= 1 then transparency = 0 end
08    transparency = transparency + .1
09end)
10 
11while true do
12    part.CFrame = part.CFrame*CFrame.new(1,0,0)
13    part.BrickColor = BrickColor.random()
14    print("debug")
15end

4 answers

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

01part = game.Workspace.skate
02local clickdetector = part.ClickDetector
03 
04clickdetector.MouseClick:Connect(function()
05    print("change transparency")
06    if part.Transparency >= 1 then
07        part.Transparency = 0
08    end
09        part.Transparency = part.Transparency + 0.1
10end)
11 
12while true do
13    part.CFrame = part.CFrame*CFrame.new(Vector3.new(1,0,0))
14    part.BrickColor = BrickColor.Random()
15    print("debug")
16    wait()
17end
Ad
Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
7 years ago
Edited 7 years ago
01part = game.Workspace.skate
02transparency = part.Transparency
03clickdetector = part.ClickDetector
04 
05clickdetector.MouseClick:Connect(function()
06    print("change transparency")
07    if transparency > 0.9 then
08     transparency = 0
09    end
10 
11    transparency = transparency + 0.1 -- If your trying to make the part fade, add this inside the loop (while true do)
12end)
13 
14spawn(function() -- This is to make sure the loop doesn't interrupt the MouseClick function
15    while true do
View all 21 lines...
Log in to vote
1
Answered by 7 years ago
01part = game.Workspace.skate
02clickdetector = part.ClickDetector
03 
04clickdetector.MouseClick:Connect(function()
05    print("change transparency")
06    if part.Transparency >= 1 then part.Transparency = 0 end
07    part.Transparency = part.Transparency + .1
08end)
09 
10while true do
11    part.CFrame = part.CFrame*CFrame.new(1,0,0)
12    part.BrickColor = BrickColor.random()
13    print("debug")
14    wait()
15end
0
random() is deprecated, I don't know if you know that. DeceptiveCaster 3761 — 7y
0
it still work so watever RodrigatorOP 172 — 7y
0
xD Audiimo 105 — 7y
0
"it still work so watever" Eventually, it may be removed so uhm.. Yeah. xAtom_ik 574 — 7y
Log in to vote
1
Answered by 7 years ago

thx u all guys im almost done with my model now

Answer this question