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 9 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.

leader = Game.Players:FindFirstChild("leaderstats")

while wait(.1) do
if leader.Quest.Value == 0 then
    script.Parent.Transparency = 0
else
    script.Parent.Transparency = 1
end
end

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
9 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.

wait(1) --keep this here

local leader = game.Players.LocalPlayer:FindFirstChild('leaderstats')
local part = workspace.Part --The part you're going to change

if leader.Quest.Value == 0 then part.Transparency = 0 else part.Transparency = 1 end

leader.Quest.Changed:connect(function(change)
    if change == 0 then
        part.Transparency = 0
    else
        part.Transparency = 1
    end
end)
Ad