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

Why won't my VIP Script give a player their tools?

The VIP script won't give tools and I'm not sure what is wrong with it :C (it's a LocalScript, by the way)

game.Players.PlayerAdded:connect(function(player)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,131852568) then
	for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
	if v:IsA'HopperBin' or v:IsA'Tool' then
	if p:FindFirstChild'Backpack' then
	v:clone().Parent = p.Backpack
	end end end end end)

game.Players.PlayerAdded:connect(function(player)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,131850638) then
	for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
	if v:IsA'HopperBin' or v:IsA'Tool' then
	if p:FindFirstChild'Backpack' then
	v:clone().Parent = p.Backpack
	end end end end end)

game.Players.PlayerAdded:connect(function(player)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,166867481) then
	for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
	if v:IsA'HopperBin' or v:IsA'Tool' then
	if p:FindFirstChild'Backpack' then
	v:clone().Parent = p.Backpack
	end end end end end)

game.Players.PlayerAdded:connect(function(player)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,131852568) and game:GetService("MarketplaceService"):PlayerOwnsAsset(player,131850638) then
	for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]:GetChildren()) do
	if v:IsA'HopperBin' or v:IsA'Tool' then
	if p:FindFirstChild'Backpack' then
	v:clone().Parent = p.Backpack
	end end end end end)
                    else
					if suit then
						print('Error! Missing tools for: '..c.Name)
					else
						print('Error! Missing suit for: '..c.Name)
					end
				end
				wait(0.15)
                db.Value = false
			end) 
		end 
    end
end

2 comments

0

There are two big problems here, 1st you have tons of replicted code, second when a player joins the game it takes time for the backpack to be setup so I would use WaitForChild.

0

Where should the changes be made? This whole thing is really stressing me out and I just want it to work.. Tried messaging you on ROBLOX but you have messages off.

1 answer

looks like you're calling a variable that has no meaning to it,

if p:FindFirstChild'Backpack' then

unless p is a shortcut for player, i wouldnt know. i rather type it out all the way

9 comments

0

At the top of the main script there is this: local p = script.Parent.Parent.Parent.Parent (I guess so it knows where the player is)

0

oh okay? you didnt post the whole script then? my bad

0

So what's wrong with it?

0

ooh. i just read it again. clone() should be Clone() --- v:Clone().Parent = p.Backpack

0

Uh.. making the c a capital letter made no difference

0

I have not coded in lua for a while, so I do not know if this will fix it. But it is proper to use () in more places, such as: p:FindFirstChild('Backpack')

0

hmm i cant figure it out can you explain what this part means? for _,v in pairs(game.ReplicatedStorage.Game_Tools[suit.Tools.Value]

0

There's different named tools (inside of models) so that part is for each character that has a Tool value (with a different name, so it knows what tools to give)

0

can you post a picture of the replicate storage?

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