• Bad key to string index (number expected, got string)
    2 replies, posted
Very new to LUA here, it's telling me my problem but I'm a bit clueless. Here's the problematic code: [CODE] function spawn_melon( ply, tr ) local size = math.random( 16, 48 ) local SpawnPos = tr.HitPos + tr.HitNormal * size local melon = ents.Create( "prop_physics" ) melon:SetModel( "models/props_junk/watermelon01.mdl" ) melon:SetPos( SpawnPos ) melon:Spawn() end concommand.Add("spawn_melon", spawn_melon) [/CODE] And the error (also in title) [CODE] [ERROR] gamemodes/gamemodename/gamemode/init.lua:146: bad key to string index (number expected, got string) [/CODE] Any pointers are appreciated. :)
There's no such argument as tr in console commands. Arguments are: Player - executor of command Command - Executed command Args - Arguments passed to the command You want to do something like this:[code] local tr = ply:GetEyeTrace() [/code]
That worked straight off the bat. Thanks for the help!
Sorry, you need to Log In to post a reply to this thread.