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

Why isnt this function script working?

Asked by
EpicLilC 150
8 years ago

~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

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?

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

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)
Ad
Log in to vote
0
Answered by 8 years ago

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)

Answer this question