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

Help me script errors? [closed]

Asked by 10 years ago

This script test if i have in my leaderstats that if i have 0 value on my quest stats if it is the part is going to be visible.

1leader = Game.Players:FindFirstChild("leaderstats")
2 
3while wait(.1) do
4if leader.Quest.Value == 0 then
5    script.Parent.Transparency = 0
6else
7    script.Parent.Transparency = 1
8end
9end

Locked by BlueTaslem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Many errors there. I'll go through them.

1: 'Game' should be lowercase

2: 'leaderstats' isn't a child of Players, use game.Players.LocalPlayer:FindFirstChild('leaderstats') to access your own leaderstats

3: this should be a localscript, in StarterGui.. then access the part with workspace.Part

4: Use a Changed event to change the part's transparency, rather than a loop. Much more efficient.

01wait(1) --keep this here
02 
03local leader = game.Players.LocalPlayer:FindFirstChild('leaderstats')
04local part = workspace.Part --The part you're going to change
05 
06if leader.Quest.Value == 0 then part.Transparency = 0 else part.Transparency = 1 end
07 
08leader.Quest.Changed:connect(function(change)
09    if change == 0 then
10        part.Transparency = 0
11    else
12        part.Transparency = 1
13    end
14end)
Ad