Scripts / help needed with my script ( im a total noob with scripting and lua )

Author
Message
DannyXGames
10
Years of Service
User Offline
Joined: 19th Nov 2014
Location: netherlands
Posted: 13th Mar 2018 23:00
I'm "trying" to make a script that spawns and object that rotates to the player SOUNDED simple enough
since I'm trying to learn a little bit of scripting I started with this but could use some tips
what am I doing wrong here ? I get an error when loading the map

pssst

Attachments

Login to view attachments
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 13th Mar 2018 23:59
GetPlayerDistance(e) is the incantation you need.

g_Entity is a table keyed on entity ID with various values in it. The error is telling you that the value you are trying to access Playerdist does not exist (hence is nil). Instead use 'if GetPlayerDistance( e ) < 150 then'.

Been there, done that, got all the T-Shirts!
PM
DannyXGames
10
Years of Service
User Offline
Joined: 19th Nov 2014
Location: netherlands
Posted: 14th Mar 2018 00:21
thanks going to give it a try thanks for the explanation amenmoses
pssst
DannyXGames
10
Years of Service
User Offline
Joined: 19th Nov 2014
Location: netherlands
Posted: 14th Mar 2018 12:49
so this is my first script maybe someone could use it its not much but a start lol

it spawns an object and make it face the player slowly
nice for chopped heads that need to be looking at the player for jumpscares and such...
have fun

pssst

Login to post a reply

Server time is: 2024-12-22 19:50:45
Your offset time is: 2024-12-22 19:50:45