I entered a script into a part that says when you click it the part gets destroyed but it dont work! help!
script.Parent.MouseButton1Click:connect(function(player) script.Parent:remove() end)
I am doing this to make a game where you dig to find treasure...so i really need help.
instead of script.parent:remove try using
script.Parent:Destroy()
script.Parent.MouseButton1Click:connect(function(player) script.Parent:Destroy end)
A part doesn't have the function "MouseButton1Click". You have to add a ClickDetector into the part, and make a global Script
Try using this in a localscript. This will not require you to put ClickDetectors in everything because honestly that's just obnoxious and unneeded.
local Player=game("GetService","Players").LocalPlayer local Mouse=Player:GetMouse() Mouse.Button1Down:connect(function() local Target=Mouse.Target if Target:IsA("BasePart") then Target:Destroy() end end)
Hope I helped!
Hey! This Should work.. but you need to do a couple of steps.
1.) First put a click detector inside of the part you want to go away.
2.) Then in insert a script inside of the part. And put this script inside. And your all set!
local sp = script.Parent function DestroyBlock() sp.Transparency = 0.1 wait() sp.Transparency = 0.2 wait() sp.Transparency = 0.3 wait() sp.Transparency = 0.4 wait() sp.Transparency = 0.5 wait() sp.Transparency = 0.6 wait() sp.Transparency = 0.7 wait() sp.Transparency = 0.8 wait() sp.Transparency = 0.9 wait() sp:Destroy() end script.Parent.ClickDetector.MouseClick:Connect(DestroyBlock)
I added the Transparency to give it a very nice effect. Enjoy!
EDIT: If you didnt want the nice effect heres the simple script
function DestroyBlock() script.Parent:Destroy() end script.Parent.ClickDetector.MouseClick:Connect(DestroyBlock)