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

How to Properly Size based on distance?

I'm attempting to make this script where the local Brick's BillboardGui's Frame will resize based on their position, so no matter where they are, they'll be able to see it. Line 20 never seems to work. Without all of the extra work, I'd see the part fine. I tried to use coroutine (Not sure if I should. First time using it), but it doesn't fire/I don't know it doesn't due to me not seeing the brick.

local Sizing = coroutine.wrap(function()
	pl = game.Players.LocalPlayer
	c = game.Workspace.CurrentCamera
	s = c.Part
	f = c.Rank.Frame
	old = 0
	while true do
	if (old < (pl.Character.Torso.Position - s.Position).magnitude) then
		f.Size = f.Size + Vector3.new(.1,0,.1,0)
		old = (pl.Character.Torso.Position - s.Position).magnitude
	elseif (old > (pl.Character.Torso.Position - s.Position).magnitude) then
		f.Size = f.Size + Vector3.new(.1,0,.1,0)
		old = (pl.Character.Torso.Position - s.Position).magnitude
		end
	end
end)

game.Players.PlayerAdded:connect(function(p)
	p.CharacterAdded:connect(function(c)
		game.Lighting.Part:clone().Parent = game.Workspace.CurrentCamera
		Sizing()
	end)
end)

1 answer

✓ Accepted answer

The problem is that you're trying to access the CurrentCamera from a Server-Side script. Only LocalScripts can access the CurrentCamera

3 comments

0

This is a LocalScript. Any tips?

0

remove the PlayerAdded and the CharacterAdded events so that those commands will execute no matter what

0

Thanks. I have another problem, but I'll make it a new question.

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