Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

It executes in-studio but it doesn't execute in-game?


local player = game.Players.LocalPlayer

local camera = game.Workspace.CurrentCamera

local pos = Vector3.new(-50, 8, 12)


player.CharacterAdded:connect(function()
	if player.Character:FindFirstChild("Head") then
		
		
		local focusing = player.Character.Head.Position

player.CanLoadCharacterAppearance = false
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0


game:GetService("RunService").RenderStepped:connect(function()
	camera.CameraType = "Scriptable"
	camera.CoordinateFrame = CFrame.new(pos, focusing) * CFrame.fromEulerAnglesXYZ(0,5,0)
end)
	
	
	
	end
end)



No output errors. Neither in the Dev Console

2 comments

0

Is FilteringEnabled true, is this in a LocalScript, if so where is it located?

0

FilteringEnabled is false, is a LocalScript, and it's located in StarterGui

1 answer

✓ Accepted answer

It works, except the StarterGui contents get copied after character spawns. You should probably make use of new, specially dedicated local script containers such as StarterPlayerScripts under StarterPlayer. http://wiki.roblox.com/index.php?title=API:Class/StarterPlayerScripts

You might also want to get rid of the FindFirstChild( "Head" ) line, since it's more than likely that head will apear split second later. Replace that if with player.Character:WaitForChild( "Head" )

Also, if you use RenderStepped with connect, it will put more stress on Lua, since it will need to make Lua threads for each RenderStepped call. Use BindToRenderStep or this sort of loop:

local renderStep = game:GetService( "RunService" ).RenderStepped
while humanoid.Health > 0 do
    -- Code
    renderStep:wait()
end

2 comments

0

It doesn't work in the StarterPlayer containers.And neither in-game.

0

I meant StarterPlayerScripts container and did you get rid of the if I told you about?

This discussion is preserved as it was. New answers, comments, and votes are closed.