Basically im making my own gamemode and i have a function that is not working.
the function :
function GM.PlayerInitialSpawn( ply )
if team.NumPlayers( TEAM_BLUE ) > team.NumPlayers( TEAM_RED) then
ply:SetTeam(3)
ply:SetModel("models/player/phoenix.mdl")
elseif team.NumPlayers( TEAM_RED ) > team.NumPlayers( TEAM_BLUE ) then
ply:SetTeam(2)
ply:SetModel("models/player/riot.mdl")
else
local r = math.Rand(1, 2)
if r == 1 then
ply:SetTeam(2)
ply:SetModel("models/player/riot.mdl")
else
ply:SetTeam(3)
ply:SetModel("models/player/phoenix.mdl")
end
end
ply:SetWalkSpeed( 250 )
Ply:SetRunSpeed( 320 )
ply:SetCrouchedWalkSpeed( 0.3 )
ply:SetDuckSpeed( 0.5 )
ply:SetNoCollideWithTeammates( true )
end
the error
[ERROR] gamemodes/jojodm/gamemode/init.lua:25: attempt to call method 'SetTeam' (a nil value)
1. unknown - gamemodes/jojodm/gamemode/init.lua:25
i tried setting the whole function in shared.lua and nothing happend pls help
dont do function GM.PlayerInitialSpawn (also its : not .) put it inside a hook, dont overwrite the function
that function is serverside only. it wont work in client or shared. only server
It'd be okay to override the function in your case as you are making a custom gamemode.
Use: math.random not math.Rand
thanks for the help! now it works
Sorry, you need to Log In to post a reply to this thread.