ReplicatedFirst:RemoveDefaultLoadingScreen() not firing in Studio - lua

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.

Related

How can I make an exclusive graphical interface only activate when a user has a gamepass in Roblox Studio?

I am starting to program in roblox, and I am making a Menu only for users who have a gamepass, I would like to know how I can make an exclusive graphical interface appear when a user has a gamepass, and the error here is that when a user buy that gamepass automatically the exclusive interface is activated to all the users of the server, I would like to know how to fix this problem.
The Script is on ServerScriptService
local MarketPlaceService = game:GetService("MarketplaceService")
local GamePass = 100725261
local Tool = game.StarterGui.ScreenGui.TPMenu
function compra(jugador)
local loTiene = false
local success, errorMensaje = pcall(function()
loTiene = MarketPlaceService:UserOwnsGamePassAsync(jugador.UserId, GamePass)
end)
if loTiene then
game.StarterGui.ScreenGui.TPMenu.Visible = true
end
end
game.Players.PlayerAdded:Connect(function(player)
compra(player)
end)
I tried to made this in a LocalScript and is not working
StarterGui is put into each Player's PlayerGui after they spawn, so editing it for one user would mean that other users would also see the changes after respawning. A better option would be to modify PlayerGui instead, like this:
function compra(jugador)
local loTiene = false
local success, errorMensaje = pcall(function()
loTiene = MarketPlaceService:UserOwnsGamePassAsync(jugador.UserId, GamePass)
end)
if loTiene then
jugador.CharacterAdded:Connect(function() -- Ran every time the player spawns
workspace:WaitForChild(jugador.Name) -- Wait for player to finish spawning
jugador.PlayerGui.ScreenGui.TPMenu.Visible = true
end)
end
end
Keep it as a Script in ServerScriptService.

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)

Cloning Locally and not locally [Lua]

I've been trying to make a sword fight game on Roblox studio. I've made a shop Gui so you can click the text button to buy the sword. It works well, You click it checks your kills and if you have enough you get the weapon. In this case, it's 0 kills. But when you take out the sword you cant use it. I've done my research and I believe that's because it's been cloned locally and not globally. Is this the case and if so how do I fix it?
The script in the Text Button:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Kills.Value >= 0 then
local clonar = game.ServerStorage.ClassicSword:Clone()
clonar.Parent = player.Backpack
end
end)
Thanks in advance!
When work needs to be performed on the server (as opposed to locally on the client), you can use RemoteEvents to communicate across the client-server boundary.
So first, you'll need to create a RemoteEvent in a shared location, like ReplicatedStorage.
Next, update your client-side LocalScript to fire the RemoteEvent :
local player = game.Players.LocalPlayer
local buyEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect( function()
buyEvent:FireServer()
end)
Finally, you need to create a Script in the Workspace or ServerScriptService that listens for that RemoteEvent and performs the work of giving the player the item :
local buyEvent = game.ReplicatedStorage.RemoteEvent
buyEvent.OnServerEvent:Connect( function(player)
if player.leaderstats.Kills.Value >= 0 then
local clonar = game.ServerStorage.ClassicSword:Clone()
clonar.Parent = player.Backpack
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.

Resources