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

This has been driving me nuts for about 24 hours at the time I post this? I'm looking for help.

Welcome. If you can help me solve this problem, you will be granted as a long time friend. I've gone bald over this script.

Basically, if you've ever seen "Mazerunner" the movie, you'll know what my game is about. "BlockRunner" is a spin-off from the movie in which players act out a life of confinement, foraging, monster killing, and survival.

So far, I've created a center safe haven and a partial maze. Some ranks are also available (8 of them). Some basic scripts and Gui's also work. For example:

  • When a player joins, the player is welcomed to the server by a Gui that is seen by everyone.
  • When a player ranks up, the player is celebrated in front of the entire server.
  • When players leave a game, their rank is saved.

I first thought everything was working fine. Until I joined the server with some friends and realized you cannot see the Gui when other players rank up or join the server. You could see your own celebrating and server join Gui, but others cannot. I also realized that the save script didn't work. And I also realized you could rank up every time you died.

So whilst I was bummed, I began fixing the bugs. I fixed the save script and the rank up when a player dies. However, I cannot fix the Gui problem. For the life of me. I cannot fix it. So I had one of my friends who's a little more knowledgeable in Lua help me out. After around 4 hours, he left and the script remained broken.

I have a Trello with screenshots of the bugs, and I also have team create enabled if you would like to help me internally. Otherwise, I'm going to try my best to show you the scripts here.

This is my base script. It controls the Gui's and the sounds.

local Leaderboard = game.Players.LocalPlayer:WaitForChild("leaderstats")
local Door = game.Workspace.Doors:WaitForChild("Door")
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
wait()

function celebrate()
	for num,player in ipairs(game.Players:GetPlayers()) do
		local CelebGui = plr.PlayerGui.Celebrate
	   	CelebGui.Frame.Visible = true
		if Leaderboard.RankVal.Value == 1 then CelebGui.Frame.TextBox.Text = ""..player.Name.." has joined the server!" 
			CelebGui.Frame.ImageLabel.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..player.Name..""
			game.Workspace.NewPlayer:play()
		else
			CelebGui.Frame.TextBox.Text = ""..player.Name.." has ranked up to "..Leaderboard.Rank.Value.."!"
			CelebGui.Frame.ImageLabel.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..player.Name..""
			game.Workspace.Celebrate:play()
		end
		wait(3)
		CelebGui.Frame.Visible = false
	end
end

function DoorOC()
	for num,player in ipairs(game.Players:GetPlayers()) do
	    local DoorGui = plr.PlayerGui.Doors
		DoorGui.Frame.Visible = true
		if Door.Value == 0 then
			DoorGui.Frame.TextBox.Text = "The door has closed."
		    game.Workspace.Door:play()
		else
			DoorGui.Frame.TextBox.Text = "The door has opened."
			game.Workspace.Door:play()
		end
		wait(3)
		DoorGui.Frame.Visible = false
	end
end

Leaderboard.RankVal.Changed:connect(function(value)
	if value == 1 then Leaderboard.Rank.Value = "Newbie" elseif
		value == 2 then Leaderboard.Rank.Value = "Member" elseif
		value == 3 then Leaderboard.Rank.Value = "Forager" elseif
		value == 4 then Leaderboard.Rank.Value = "Watcher" elseif
		value == 5 then Leaderboard.Rank.Value = "Mason" elseif
		value == 6 then Leaderboard.Rank.Value = "Warrior" elseif
		value == 7 then Leaderboard.Rank.Value = "Runner" elseif
		value == 8 then Leaderboard.Rank.Value = "Elder"
	end
end)

script.Parent.NPEvent.OnClientEvent:connect(function(player)
	celebrate()
end)

Door.Changed:connect(function(value)
	wait(1)
	DoorOC()
end)

wait()
Leaderboard.RankVal.Value = 1 -- This was adding everytime the player died I jsut changed it to = 1 instead of + 1

This is the leaderboard script. Ignore the word tycoon, as it is partially from my other game.

print("Leaderboard is running.")

function onPlayerEntered(newPlayer)
    repeat wait() until newPlayer.Character
	for i, v in pairs(game.Players:GetChildren()) do
		v.PlayerGui.NPEvent.FireClient(v, newPlayer)
	end
    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"

    local cash = Instance.new("StringValue")

    cash.Name = "Rank" 
	cash.Value = 0
	
	local val = Instance.new("IntValue")
	val.Name = "RankVal"
	val.Value = 0

--check if the player owns your gamepass
    if game:GetService("MarketplaceService"):PlayerOwnsAsset(newPlayer, 384198804) then
    cash.Value = 0 -- change cash to 500,000 (can't have a comma)
	else
	cash.Value = 0
    end
    cash.Parent = stats   
    stats.Parent = newPlayer
    val.Parent = stats
end
game.Players.ChildAdded:connect(onPlayerEntered)

This is a picture of the Gui system and main parts of the game in explorer. http://imgur.com/7LvAzFB

Again, any help is *GREATLY *appreciated.

Thanks, Tradesmark

2 comments

0

Use a remote event to tell the server who has ranked up, and from there use a remote event to fire all clients with the player's name that ranked up and on each client, show the appropriate GUI.

0

That is what I attempted to do. But now the Gui's do not show at all.

1 answer

✓ Accepted answer

Hmm so your main problem here is that you're trying access another player's "PlayerGui" from a localscript. As far as local scripts go, this is a no-go and for whatever reason always has been even before filtering enabled was a thing.

In order to combat this what you want to do is create your celebrate function so it will only update that particular client's GUI, attach it to the NPEvent, and then fire all clients.

So for example:

-- server script
while wait(1) do
	game.ReplicatedStorage.RemoteEvent:FireAllClients();
end;

Then in the local script:

-- client script
function celebrate()
	local winners = {};
	for _, player in ipairs(game.Players:GetPlayers()) do
		table.insert(winners, player.Name);
	end;
	script.Parent.TextLabel.Text = "winners: " .. table.concat(winners, ", ");
end;

game.ReplicatedStorage:WaitForChild("RemoteEvent").OnClientEvent:connect(function()
	celebrate();
end);

5 comments

0

What do I replace in the LocalScript? I'm not sure how to implement either of those scripts accurately.

0

The above is just an example. I would build the celebrate function with a parameter for a string of the player's name who just levelled up. Then when I call FireAllClients I pass the updated player's name as a parameter.

0

I wouldn't call myself an intermediate scripter so I'm having trouble understanding what exactly I need to do. would you mind joining Team Create and showing me rather than telling me? I think I would understand more that way.

0

I'm eating lunch rn lol, but if you give me approx 20 mins I'll come in.

0

Alright I sent you an invite. Here's the place https://www.roblox.com/games/407374706/BlockRunner-Beta

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