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

Why won't image show when leaderstats is high enough?

I had to reupload this post because I wasn't getting any answers that worked. So, I want to make a collecting game and the catalog shows the collectibles you have. I made all of the collectibles leaderstats so you can save it. So, I made the image in the gui have a value and a script. Here it is:

	local ting = 0
mlvl = script.Parent.Lvl.Value 
if ting == 0 then
ting = 1

if check ~= nil then

local user = game.Players.LocalPlayer
local stats = user:findFirstChild("leaderstats")
local Lvl = stats.Molly

if stats ~= nil and Lvl.Value >= mlvl then

script.Parent.Parent.Molly.ImageTransparency = 1

end

if Lvl.Value < mlvl then

script.Parent.Parent.Molly.ImageTransparency = 0
 
	       end	    end
	 	    ting = 0
	    end

So if you have this much leaderstat, the image will show up, basically. So, the problem is, the image doesn't show up. PrismaticFruits had tried to help and I'm grateful for them trying, but it didn't work. Here's their script:

local ting = 0
mlvl = script.Parent.Lvl.Value
 
if ting == 0 then
ting = 1

if check ~= nil then

local user = game.Players.LocalPlayer
local stats = user:findFirstChild("leaderstats")
local Lvl = stats.Molly

if stats ~= nil and Lvl.Value >= mlvl then
	 
script.Parent.Parent.Molly.Visible = false

end
	 
	        if Lvl.Value < mlvl then
	 
        script.Parent.Parent.Molly.Visible = true
 
	       end
	    end
	 
	    ting = 0
	    end

Thank you!

3 comments

0

4 ifs but 3 ends? thats maybe why.

0

any errors

0

@123nabilben123 Nope, no errors...

1 answer

I'm pretty convinced that the problem is how you find the "Molly" value inside your leaderstats. This should work: (not 100% sure)

local playervariable = game.Players.LocalPlayer
local stats = playervariable:WaitForChild("leaderstats")
local valuevariable = stats:WaitForChild("Molly")

Another problem might be if it's a server script or local script. Since you can't use LocalPlayer on server scripts, try using a server script instead of a local script (You will need player joined event though).

game.Players.PlayerAdded:Connect(function(player)
	local stats = player:WaitForChild("leaderstats")
	local valuevariable = stats:WaitForChild("Molly")

(Btw, if none of them doesn't work, try changing WaitForChild from the valuevariables to FindFirstChild, because I don't have your explorer so I can't really test it for myself). I hope it worked!

3 comments

0

Hi, thank you for responding. Unfortunately, neither of the scripts work; and what's a server script?

0

Server script is a scripts that acts on the server (it's the default script named "Script") and local scripts are scripts that act on the client(you prabably know how does a local script look like).

0

It's a server script then.

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