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

How would I be able to make a gui appear via leaderstats or touching a part?

How would I be able to make a gui appear using leaderstats or touching a part i tried this but it doesnt seem to work

function onTouch(Part234)

script.Parent.Visible = true
wait(5)
script.Parent.Visible = false
script.Parent:TweenPosition(UDim2.new(0, 0,0, 0), 'Out', 1)

end

script.Parent.Touched:connect(onTouch)

2 answers

To do a gui appear on depending on leadstats you can do something like this:

Insert a local script in the main frame of the gui and type this:

I may have miss spelled LeadStats Replace "ValueName" by the name of the value (ex: gold, money, level..) Replace "number" by the required number u must have

while wait () do
if game.Players.LocalPlayer.LeadStats.ValueName.Value == number then
script.Parent.Visible = true else
script.Parent.Visible = false
end


1 comment

0

didnt work unfortunately

To base it on Leaderstats follow these steps:

Step 1: Put a LocalScript into the ScreenGui

Step 2: Type the following into the LocalScript

local Player = game.Players.LocalPlayer
local Stat = Player.LeaderStats.Stat --Change Stat to the name of your LeaderStat
local Frame = Player.PlayerGui.ScreenGui.Frame --Change "ScreenGui" to the Name of the ScreenGui and change "Frame" to the name of the Frame
local LevelUp = Stat.Value + 1

while wait() do
  if Stat ~= nil then
    if Stat.Value == LevelUp then -- LevelUp is the Level after the players current level
        --If you want you can make some text in the frame say the value of their level here
    	  Frame.Visible = true
    	  wait(5)
    	  Frame:TweenSize(UDim2.new(0,0,0,0), "Out", "Quint", 3)
    	  Frame.Visible = false
   	  LevelUp.Value = LevelUp.Value + 1
        --You would want to make the sixe back to normal here if you want it to play again the next level 
  end
end
end

To base it on Leaderstats follow these steps:

Step 1: Put a LocalScript into the ScreenGui

Step 2: Type the following into the LocalScript

script.Parent.Touched:connect(function(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") ~= nil then
      local LS = script.LocalScript:Clone() -- this script is the LocalScript
      local Player = Hit.Parent:GetPlayerFromCharacter
      LS.Parent = Player.PlayerGui.ScreenGui
      LS.Disabled = false
    end
end)

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