~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
function onTouch() local noob = workspace.Part wait(1) noob.Shape.Block = false wait(1) noob.Shape.Ball = true wait(2) noob:Destroy() print('get rekt noob') end workspace.Part.Touched:connect(onTouch)
By the way i'm just starting to learn how to script so I was trying to use functions but for some reason this doesn't work. Can someone explain why?
There are a few issues here. First of all, this will only work once, so it will error after the first time noob
is destroyed. The easiest way to fix this is to add a debounce that never gets un-bound:
Next, I'm not sure where you got the idea of using <Part>.Shape.<Shape> = <bool>
, or what you expect it to do, but you set that property by using the PartType Enum.
local deb = false function onTouch() if deb then return end deb = true local noob = workspace.Part wait(1) noob.Shape = Enum.PartType.Block --You set this to false, so I'm not sure what you meant to do here. wait(1) noob.Shape = Enum.PartType.Ball wait(2) noob:Destroy() print('get rekt noob') end workspace.Part.Touched:connect(onTouch)
If you want to make it work normally then, try this. message me if it's not;
function onTouch(part) local noob = workspace.Part wait(1) noob.Shape = Enum.PartType.Block wait(1) noob.Shape = Enum.PartType.Ball wait(2) noob:Destroy() print("get rekt noob") end connect(onTouch)