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

Why is the second player not getting the hopperbin?

Hi - seeing as my previous post about this problem remains unanswered (see htts://scriptinghelpers.org/questions/9281/why-is-the-tool-not-being-distributed

  • I felt it would be necessary to pick out the problematic area, or where I believe the problem is originated.

Perhaps I should explain in more detail what the problem is - The GameTool (Hopperbin) is inside of a script that distributes most of the scripts information - and the maps. This script works by copying the GameTool from the Workspace (Workspace.Distribution, more accurately), and putting it into the backpack of the player. The script inside of the Hopperbin then loads the rest of the game, including it's GUI(s), and such.

The first player to connect is getting the tool, while all other players after him/her are not.

I believe the problem is originating from -

game.Players.PlayerAdded:connect(function(player)
	consoleMessage(player.Name.." has connected.","Toothpaste")
	player.CharacterAdded:connect(function()
		gtool:clone().Parent = player.Backpack
		player.Backpack["GameTool"].Archivable = false
		player.Backpack["GameTool"]["woop"].Archivable = false
	end)
  • although I am open to other suggestions. The other post has the entire script available.

A note to administrators: If you plan on deleting this post, please delete the older one and leave the more explained one here.

Thanks in advance, -Dragon

'gtool' is specified here -

gtool = script.GameTool:clone()
script:remove()

in the same script.

EDIT: For Dominic and dueling

remove() is not present in the script, as the script (from the point above) continues to do

local warning = game.Lighting.Resources.GUI.Warning:clone()
	Spawn(function()
		repeat wait(0) until player:findFirstChild("PlayerGui") and player.PlayerGui:findFirstChild("Menu")
		warning.Parent = player.PlayerGui
		local leedstat = Instance.new("BoolValue",player)
		leedstat.Name = "leaderstats"
		Instance.new("StringValue",leedstat).Name = "Users"
		wait(4)
		warning.Agree:TweenPosition(UDim2.new(0.35,0,.7,0),"Out","Quad",1,true)
		warning.Agree.MouseButton1Click:connect(function()
			warning.Agree:TweenPosition(UDim2.new(0.5,-100,2,0),"Out","Quad",1,true)
			warning.Frame:TweenPosition(UDim2.new(0,0,2,0),"Out","Quad",0.7,true)
			game.Debris:AddItem(warning,2)
			player.PlayerGui.Menu.Frame.Active = true
		end)
	end)
end)

which is unrelated (I think) to the problem I am having.

3 answers

You are going to have to remove line two, as line two is removing the script and stopping the code.

replace line 1 and two with:

gtool = script:FindFirstChild("GameTool")
gtoolC = gtool:clone()

1 comment

0

The first player is still the only one getting the script, and that has also broke the script entirely - and I have reverted it to the version before that.

gtool:clone().Parent = player.Backpack

gtool = script.GameTool:clone()

Remove the :clone() from the gtool variable.

EDIT:

game.Players.PlayerAdded:connect(function(player)
    consoleMessage(player.Name.." has connected.","Toothpaste")
    player.CharacterAdded:connect(function()
        local tool = gtool:clone()
	tool.Parent = player.Backpack
        tool.Archivable = false
    end)
end)

11 comments

0

Follow my suggestion before the edit as well.

0

That prevents both player from getting the tool.

0

Nevermind my previous post - I will try the edit now.

0

Both edits appear to have broken the script.

0

Where are you testing this?

0

Inside of the FPS - and I am reverting the version each time.

0

That is - reverting the script to an archived copy.

0

I accidentally added an extra dot, try it again.(Unless you caught it beforehand)

0

I caught it before hand (tool.Archivable, yes?) I've removed it.

0

Works for me, so it is as I thought, remove "script:remove()"

0

Please see new edit in original post.

I will refer to my own knowledge on this one.


This is how I see your script now:

gtool = script.GameTool:clone()
game.Players.PlayerAdded:connect(function(player)
    consoleMessage(player.Name.." has connected.","Toothpaste")
    player.CharacterAdded:connect(function()
        gtool:clone().Parent = player.Backpack
        player.Backpack["GameTool"].Archivable = false
        player.Backpack["GameTool"]["woop"].Archivable = false
    end)
script:remove()

There are a couple things I noticed right off the bat:

You stated gtool as: gtool = script.GameTool:clone() and then later on in the code, you stated to gtool:clone(). Basically this is what the code reads: script.GameTool:clone():clone().Parent = player.Backpack and messes up at :clone():clone().

I suggest you define "gtool" as an object, instead of a clone. Then clone it under the actual function.

You also should have a second end) due to the fact you have two functions.

another thing is remove()has been deprecated. This means it no longer works. What you should use instead is :Destroy(). If you destroy the script, it will not run again.

I hope this helped. I will be glad to assist you if you have any further questions on this topic.

1 comment

0

Please see original post (and - I have corrected the :clone():clone(), thank you for pointing that out.

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