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

Can anyone figure this out?

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.

1 comment

0

Is 'zombiehand' a model?

1 answer

✓ Accepted answer

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)

1 comment

0

thxs

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