Shania Posted November 25, 2016 Share Posted November 25, 2016 Hey Guys can you tell me what is wrong this? function makeTargetFollow ( target ) if ( target ) and ( getElementType(target) == "player" ) then local x,y,z = getElementPosition( source ) local tx,ty,tz = getElementPosition( target ) if ( getDistanceBetweenPoints3D( x,y,z,tx,ty,tz ) <= 7 ) then toggleAllControls( target, false ) setControlState( target, "forwards", true) setTimer( updateRotation, 500, 0, source, target ) end end end addEventHandler( "onPlayerTarget", root, makeTargetFollow ) function updateRotation( player, target ) if ( isElement(player) ) and ( isElement(target) ) then local x,y = getElementPosition( player ) local tx,ty = getElementPosition( target ) local rot = findRotation(tx,ty,x,y) setElementRotation ( target, 0, 0, rot ) end end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end Link to comment
ViRuZGamiing Posted November 25, 2016 Share Posted November 25, 2016 What happens and is there a debugscript 3 error? Link to comment
Shania Posted November 25, 2016 Author Share Posted November 25, 2016 4 minutes ago, ViRuZGamiing said: What happens and is there a debugscript 3 error? its not working Link to comment
ViRuZGamiing Posted November 25, 2016 Share Posted November 25, 2016 1 minute ago, Shania said: its not working Try putting output's in your code and see where it runs and where it doesn't Link to comment
LoPollo Posted November 25, 2016 Share Posted November 25, 2016 Also read that before posting Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now