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

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

 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

✓ Accepted answer
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)

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

2 comments

0

Actually, I got it to work not by that, I just needed a touch interest function.

0

^ I meant a connect: thing.

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