Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to Properly Size based on distance?

Asked by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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

Log in to vote
0
Answered by 10 years ago

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

0
This is a LocalScript. Any tips? Shawnyg 4330 — 10y
0
remove the PlayerAdded and the CharacterAdded events so that those commands will execute no matter what TurboFusion 1821 — 10y
0
Thanks. I have another problem, but I'll make it a new question. Shawnyg 4330 — 10y
Ad

Answer this question