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

Can anyone figure this out?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
bool = false
grave = script.Parent.Parent
zombiehand = script.Parent
Touch = grave.touch
position = grave.p2.Position
zombiehandcframe = zombiehand.Position

function handpopup(hit) 
    if hit.Parent and hit.Parent.Humanoid then
        if hit.Parent.Parent ~= nil then
            if bool == false then       
                bool = true
                local move = Vector3.new(1,1,1)
                for t = 0, position, move do
                    wait(0.1)
                    zombiehand = t
                end
            end
        end
    end
end

Touch.Touched:connect(handpopup)

So I have a grave built and I when the player touch the grave the zombie hand pop out but I can't seem to make the hand pop out using loop.

0
Is 'zombiehand' a model? Goulstem 8144 — 8y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

for loops don't take Vector3s as parameters, they use numbers. zombiehand is also initially defined as script.Parent and on line 16 you're changing it to a number, which is strange. Instead of trying to use objects in a for loop, interpolate the position:

bool = false
grave = script.Parent.Parent
zombiehand = script.Parent
Touch = grave.touch
position = grave.p2.Position
zombiehandcframe = zombiehand.Position

function handpopup(hit) 
    if hit.Parent and hit.Parent.Humanoid then
        if hit.Parent.Parent ~= nil then
            if bool == false then       
                bool = true
                local cframe=zombiehand.CFrame
                for t = 0, 1, 1/(cframe.p-position).magnitude do
                    wait(0.1)
                    zombiehand.CFrame = cframe-cframe.p+cframe.p:lerp(position,t)
                end
            end
        end
    end
end

Touch.Touched:connect(handpopup)
0
thxs BuilderCosmic 43 — 8y
Ad

Answer this question