Garry's Mod Wiki

Garry's Mod Wiki

  Player:SpectateEntity( Entity entity )

Description

Makes the player spectate the entity.

To get the applied spectated entity, use Player:GetObserverTarget.

Arguments

1 Entity entity
Entity to spectate.

Example

Creates a entity, spectates it and after 5 seconds, stops spectating it.

local ent = ents.Create( "prop_physics" ) ent:SetModel( "models/hunter/misc/sphere025x025.mdl" ) ent:SetPos( Vector( 0, 0, 0 ) ) ent:Spawn() for _, ply in ipairs( player.GetAll() ) do ply:Spectate( OBS_MODE_CHASE ) ply:SpectateEntity( ent ) ply:StripWeapons() timer.Simple( 5, function() if IsValid( ply ) then ply:UnSpectate() ply:Spawn() end end ) end

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...