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

Help on script?

I want it to be like when you hold click on the brick it disappears and when you let go it reappear, but i am not sure how i do it.

function hold()
	script.Parent.Transparency = 1
end
function unhold()
	script.Parent.Transparency = 0
end

script.Parent.ClickDetector.MouseClick:connect(hold) -- my problems i don't know if MouseClick is correct
script.Parent.ClickDetector.MouseClick:connect(unhold) -- my problems i don't know if MouseClick is correct

1 answer

✓ Accepted answer

In order to do this, you would have to access the players mouse. Try this:

function hold(Plr)
	script.Parent.Transparency = 1
	local Val=Plr.PlayerGui.MouseValue
	repeat wait() until Val.Value==false or Plr==nil
	script.Parent.Transparency=0
end

script.Parent.ClickDetector.MouseClick:connect(hold)

Try using that script. I think that it should work, but if not, leave a comment below, and I'll see what I can do.

UPDATE:

Put that first script I updated in the original brick, and then put a BoolValue (Name it MouseValue(Or something else)) in the Startergui with this LOCALscript in it:

Plr=game.Players.LocalPlayer
Mouse=Plr:GetMouse()

Mouse.Button1Down:connect(function()
	script.Parent.Value=true
end)

Mouse.Button1Up:connect(function()
	script.Parent.Value=false
end)

Sorry about the long wait. This is untested only because I don't have time right now. Go ahead and test it and tell me how it works. Make sure you do everything correctly, and I think it should. Again, sorry for the long wait.

13 comments

0

wait when i tested it not on roblox studio it did not work

0

Are you sure? I tested it and it worked perfectly. If somethings wrong, i'll try to fix it, but as far as I can see it should work fine.

0

so your sure you tested it in a real game not in roblox studio?

0

Oh...I see. I'll work on it, hold on.

0

Sorry about the long wait. It's not tested because I don't have time right now, but I did update it. Follow the instructions and it should work fine I think. Hope I helped :P

0

I did not work i think the problem is around Val in the first script

0

Whoops, fixed it. Try it now. Sorry about that...

0

Sorry to say but it only turned invisible so :(

0

Ermagerd, sorry. Wait till I get to an actual computer tonight and i'll test it myself before making another update. Sorry about how long this is takin, i wont give up tho.

0

thanks :)

0

Ok, finally! I got it to work and it's tested this time. So sorry about how long that took, but I think I got it this time. Please let me know just to make sure :P

0

thanks it works sorry i did not check it for 2 days i did not had time to go on the computer :)

0

Lol no prob.

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