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

This script isn't working and doesn't have any errors, what is the problem?

Asked by
Moosee 62
10 years ago
 function onTouched(Brick)
Brick = script.Parent
game.Workspace.Brick.Transparency = 1 
wait(1) 
game.Workspace.Brick.Transparency = 0 
game.Workspace.Brick.Name = Worked 
end 
if game.Workspace.Brick.Name==Worked 
    then print("Worked! :D") 

    end

What is the problem here, It's supposed to make a brick go transparent then become nontransparent if you touch it.

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago
script.Parent.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
game.Workspace.Brick.Transparency = 1 
wait(1) 
game.Workspace.Brick.Transparency = 0 
game.Workspace.Brick.Name = 'Worked' 
end 
if game.Workspace.Brick.Name=="Worked" then

end print("Worked! :D") 

    end)

Ad
Log in to vote
-3
Answered by 10 years ago

You have to have quotations so:

 function onTouched(Brick)
Brick = script.Parent
game.Workspace.Brick.Transparency = 1 
wait(1) 
game.Workspace.Brick.Transparency = 0 
game.Workspace.Brick.Name = "Worked"
end 
if game.Workspace.Brick.Name == "Worked"
    then print("Worked! :D") 

    end

or you could do this and be able to change it to what ever

Worked = "Worked"
 function onTouched(Brick)
Brick = script.Parent
game.Workspace.Brick.Transparency = 1 
wait(1) 
game.Workspace.Brick.Transparency = 0 
game.Workspace.Brick.Name = Worked 
end 
if game.Workspace.Brick.Name==Worked 
    then print("Worked! :D") 

    end

0
Actually, I got it to work not by that, I just needed a touch interest function. Moosee 62 — 10y
0
^ I meant a connect: thing. Moosee 62 — 10y

Answer this question