Roblox leaderstats will not display - lua

So I have tried many variations of leaderstats scripts. Here is one in which should work just fine to my knowledge..... any thoughts on this? leaderstats gui will not display, but the script functions as I can tell through playing the game in studio to test and i notice under player it creates the folder and int value etc.
function showLeaderstats(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("IntValue",leaderstats)
Cash.Name = "Cash"
Cash.Parent = leaderstats
end
game.Players.PlayerAdded:Connect(showLeaderstats)

It works fine for me. Make sure the leaderboard isn't minimized, the code is in a script and not a local script, the script is in ServerScriptService or the workspace.

Hey sorry to see that no one responded. You should try:
instead of a folder do this:
local leaderstats = Instance.new("IntValue")
--after that, you can assign it's parent to:
leaderstats.Parent = stats
Let me know if this worked!

Related

Why is my jump boost gamepass in roblox not working?

So I decided to make a jump boost gamepass in roblox but when I test and I have my gamepass it doesn't work.
here is my code
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local PlayerUserID = Players.LocalPlayer.UserId
print(PlayerUserID)
Players.LocalPlayer.CharacterAdded:Connect(function(char)
print(MarketplaceService:UserOwnsGamePassAsync(PlayerUserID, 21723718))
if MarketplaceService:UserOwnsGamePassAsync(PlayerUserID, 21723718) then
char.Humanoid.UseJumpPower = true
char.Humanoid.JumpPower = 100
end
end)
it is a server script on ServerScriptService
I cant see any output that comes from the script.
You cannot use LocalPlayer in a Server Script. You will have to get the player via other methods.
Check out the Roblox gamepass guide.
Your server script is targeting an object that doesn't exist. game.Players.LocalPlayer is only defined in localscripts.
To get around this, use Players.PlayerAdded
Use this code instead
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if MarketplaceService:UserOwnsGamePassAsync(PlayerUserID, 21723718) then
char.Humanoid.UseJumpPower = true
char.Humanoid.JumpPower = 100
end
end)
end)

I can't access the text of a TextBox in roblox LUA

Alright, So I've tried other stackoverflows, But I can't get it to work.
Heres the code
script.Parent.MouseButton1Click:Connect(function()
local plr = game.StarterGui.ScreenGui.title.Frame.plr
print(plr.Text)
local gp = game:GetService("ReplicatedStorage"):WaitForChild("GetPlr")
gp:FireServer(plr.Text)
end);
the frame.Plr part is the textbox
When I do plr.Text it doesn't get the current input.
I hope yall have good anwsers
And I hope you have a good day :D
UI elements that are placed in StarterGui act as a template. They are copied into each player's PlayerGui when their Character spawns in the world.
Your issue is that a player has put text into their copy of the ui, which is located in the PlayerGui, and you are trying to pull that text out of the template in StarterGui.
So in your LocalScript, try updating the path to the text box to point at the player's PlayerGui :
local PlayerService = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function()
local pg = PlayerService.LocalPlayer.PlayerGui
local plr = pg.ScreenGui.title.Frame.plr
print(plr.Text)
local gp = ReplicatedStorage.GetPlr
gp:FireServer(plr.Text)
end)

Roblox Lua Give LocalPlayer weapon doesn't work,

My code: https://justpaste.it/87evk
local original = game:GetService("ReplicatedStorage"):FindFirstChild("CloneSmoke")
local tool = script.Parent
local copy = original:Clone()
tool.Activated:Connect(function()
print("Running...")
local sound = script.Parent.Sound
copy.Parent = script.Parent.Handle
sound:Play()
wait(3)
tool:Destroy()
local plr = game.Players.LocalPlayer
local weapon = game.ReplicatedStorage.Jutsus.Momoshiki["Momoshikis Sword"]
local w2 = weapon:Clone()
w2.Parent = plr.Backpack
end)
Idk what i have to do here to get the Player and give him a Weapon.I tried much but i dont get the right Soloution.
It were nice wenn you help me
First off, make sure this is in a LocalScript
Also change local original = game:GetService("ReplicatedStorage"):FindFirstChild("CloneSmoke") to local original = game:GetService("ReplicatedStorage"):WaitForChild("CloneSmoke") This is because the script loads faster than items in the game, so chances are, the sword hasn't loaded into the game by the time the script runs; the script won't work if it doesn't find the object you are trying to reference.

ReplicatedFirst:RemoveDefaultLoadingScreen() not firing in Studio

I'm back with yet another problem. I'm trying to make a custom loading screen for my game, but RemoveDefaultLoadingScreen doesn't seem to be firing. Can anyone help me with this? Here's my code:
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
ReplicatedFirst:RemoveDefaultLoadingScreen()
local TweenService = game:GetService("TweenService")
local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(1)
local Loading = ReplicatedFirst.Load
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.IgnoreGuiInset=true
local Bar = Loading.Frame.TextLabel
ScreenGui.Name = "LoadScreen"
Loading.Parent = ScreenGui
ScreenGui.Parent = PlayerGui
local Info = TweenInfo.new(0.7,Enum.EasingStyle.Cubic,Enum.EasingDirection.InOut,0,true,0)
local Tween = TweenService:Create(Bar,Info,{Position=UDim2.new(0.8,0,0.6,0)})
spawn(function()
while true do
Tween:Play()
Tween.Completed:Wait()
end
end)
if not game:IsLoaded() then
game.Loaded:Wait()
end
for i=0,1,0.1 do
Loading.BackgroundTransparency=i
Bar.TextTransparency=i
Loading.Frame.Load.TextTransparency=i
wait()
end
ScreenGui:Destroy()
Everything works fine, except that the third line doesn't work in Studio. Is it supposed to be this way? Help would be greatly appreciated.
I tested it, it works just fine in Roblox Studio. Note this, though:
In studio the load screen goes away almost instantly, so you won't see much of a difference.
I'd put a wait(5) in your script before the if not game:IsLoaded() then line, that will simulate a 5 second load. Then you can play with having vs not having the ReplicatedFirst:RemoveDefaultLoadingScreen() command present, and you'll see the difference.

Roblox Studio Admin GUI set player scores

Hi there i'm a little stuck on how i would set a players cash through a admin gui i'm not to familiar with this language and could use a little help.
here is what the gui looks like
GUI Image
Explorer Image
code Image
here is what i have so far not sure if im on the right lines or not aha
button = script.Parent.MouseButton1Click:connect(function()
local stat = Instance.new("IntValue")
stat.Parent = script.Parent.Parent.casgplayertext.Text
stat.Name = "Cash"
stat.Value = script.Parent.Parent.cashetxt
game.Players.childAdded:connect()
end)
The statistics values should be children of a model or folder object named 'leaderstats', located in the player (for instance: Player1>leaderstats>Cash). So you need a script that creates this 'leaderstats'-named object with the statistics you want. So you would get something like this:
local players = game:WaitForChild("Players")
local function initializeLeaderstats(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
local cashStat = Instance.new("IntValue", stats)
cashStat.Name = "Cash"
stats.Parent = player
end
players.PlayerAdded:connect(initializeLeaderstats)
Then you need some code to manipulate the value of someones cash statistic in another script. You can write a function that uses 2 parameters: the player name and the amount of cash.
local players = game:WaitForChild("Players")
local function setCashValue(playerName, value)
local player = players:FindFirstChild(playerName)
if player then
local leaderStats = player.leaderstats
local cashStat = leaderStats.Cash
cashStat.Value = value
end
end
You can call this function when you have clicked the 'Submit' button with the 2 parameters: the player name and the amount of cash.

Resources