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

LocalScript not doing what it's supposed to?

Asked by 9 years ago

I have a localscript and it is supposed to toggle visibility when a player reaches certain leaderstats. However, when one player reaches the stats, the whole server gets the visibility toggled. I'm a bit new to scripting so I'm not sure where I went wrong.

01while true do
02    for i,v in pairs(game.Players:GetChildren()) do
03    if v.leaderstats.Level.Value >= 2 then
04    script.Parent.Main.Archer.Visible = true
05    script.Parent.Covers.ArcherCover.Visible = false
06    script.Parent.Frame.Archer.Visible = true
07    end
08    if v.leaderstats.Level.Value >= 3 then
09        script.Parent.Main.Skeleton.Visible = true
10        script.Parent.Covers.SkeletonCover.Visible = false
11        script.Parent.Frame.Skeleton.Visible = true
12    end
13    if v.leaderstats.Level.Value >= 4 then
14        script.Parent.Main.LavaBaron.Visible = true
15        script.Parent.Covers.LavaBaronCover.Visible = false
View all 25 lines...

1 answer

Log in to vote
0
Answered by 9 years ago

Use a LocalScript instead of a script. This makes thing much easier for you. All you need to do is to create a LocalScript inside either in the StarterPack or StarterPlayer>StarterPlayerScripts, which ever one you prefer.

Also I changed your script:

1for i,v in pairs(game.Players:GetChildren()) do

Instead of a for loop. You can do this instead.

01local v = game.Players.LocalPlayer -- This makes things much easier! and Much more simple.
02 
03while true do
04    if v.leaderstats.Level.Value >= 2 then
05      script.Parent.Main.Archer.Visible = true
06      script.Parent.Covers.ArcherCover.Visible = false
07      script.Parent.Frame.Archer.Visible = true
08    end
09    if v.leaderstats.Level.Value >= 3 then
10        script.Parent.Main.Skeleton.Visible = true
11        script.Parent.Covers.SkeletonCover.Visible = false
12        script.Parent.Frame.Skeleton.Visible = true
13    end
14    if v.leaderstats.Level.Value >= 4 then
15        script.Parent.Main.LavaBaron.Visible = true
View all 26 lines...

Just copy and paste this code into the LocalScript you created. I hope this worked for you.

Ad

Answer this question