generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: After I die i don't get my tools back?

Previous Thread :: Next Thread 
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 08:34 PM
I'm using two scripts.
One is in a gui button and the other is in workspace

Local Script Script (GUI) code -

players = {}
Humanoids = {}

debounce = false

game.Players.PlayerAdded:connect(function(player)
table.insert(players, player)
print(players)
end)
while true do
wait()
players = game.Players:GetChildren()
for i,v in pairs (players) do
local humanoid = v.Character
table.insert(Humanoids, humanoid)
end
for i,v in pairs (Humanoids) do
wait()
local humanoid = v:FindFirstChild("Humanoid")
debounce = true
wait()
local PlayerName = v.Name
local player = game.Players:FindFirstChild(PlayerName)
local name = v.Name
local x1 = game.Lighting:FindFirstChild("CFrame"..name) -- change to lighting tool name
local x2 = game.Lighting:FindFirstChild("Color"..name) -- change to lighting tool name
local x3 = game.Lighting:FindFirstChild("GravityCoil"..name) -- change to lighting tool name
local x4 = game.Lighting:FindFirstChild("Material"..name) -- change to lighting tool name
local x5 = game.Lighting:FindFirstChild("ResizeTool"..name) -- change to lighting tool name
local x6 = game.Lighting:FindFirstChild("Sword"..name) -- change to lighting tool name
local x7 = game.Lighting:FindFirstChild("RunTool"..name) -- change to lighting tool name
local x8 = game.Lighting:FindFirstChild("Teleport"..name) -- change to lighting tool name
local x9 = game.Lighting:FindFirstChild("Anchor"..name) -- change to lighting tool name
if x1 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x2 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Color -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x3 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.GravityCoil -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x4 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Material -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x5 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.ResizeTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x6 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Sword -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x7 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.RunTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x8 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Teleport -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x9 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Anchor -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end

end
debounce = false

end





end


Workspace Script code -

players = {}
Humanoids = {}

debounce = false

game.Players.PlayerAdded:connect(function(player)
table.insert(players, player)
print(players)
end)
while true do
wait()
players = game.Players:GetChildren()
for i,v in pairs (players) do
local humanoid = v.Character
table.insert(Humanoids, humanoid)
end
for i,v in pairs (Humanoids) do
wait()
local humanoid = v:FindFirstChild("Humanoid")
debounce = true
wait()
local PlayerName = v.Name
local player = game.Players:FindFirstChild(PlayerName)
local name = v.Name
local x1 = game.Lighting:FindFirstChild("CFrame"..name) -- change to lighting tool name
local x2 = game.Lighting:FindFirstChild("Color"..name) -- change to lighting tool name
local x3 = game.Lighting:FindFirstChild("GravityCoil"..name) -- change to lighting tool name
local x4 = game.Lighting:FindFirstChild("Material"..name) -- change to lighting tool name
local x5 = game.Lighting:FindFirstChild("ResizeTool"..name) -- change to lighting tool name
local x6 = game.Lighting:FindFirstChild("Sword"..name) -- change to lighting tool name
local x7 = game.Lighting:FindFirstChild("RunTool"..name) -- change to lighting tool name
local x8 = game.Lighting:FindFirstChild("Teleport"..name) -- change to lighting tool name
local x9 = game.Lighting:FindFirstChild("Anchor"..name) -- change to lighting tool name
if x1 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x2 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Color -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x3 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.GravityCoil -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x4 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Material -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x5 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.ResizeTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x6 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Sword -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x7 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.RunTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x8 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Teleport -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
end
if x9 ~= nil then
local check1 = player.Backpack:FindFirstChild("CFrame"..name)
local check2 = player.Character:FindFirstChild("CFrame"..name)
if check1 and check2 == nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Anchor -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end

end
debounce = false

end





end

Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 08:36 PM
My only problem is it won't give me the tool back after i die? Please help me I'm new to scripting but i spent 10 hours (no exaggeration) working on this so that it works... It worked once so that when you died you get your tools back but if you die again you lose everything. Please guide me towards what I need to to look at and fix or add
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 08:42 PM
At the top where it says
game.Players.PlayerAdded:connect(function(player)

Add this
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)


And on the very last line where it says

end

Change it to

end)
end)
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:06 PM
I changed the workspace code up a bit. Now you get your stuff back after you die but it gives you like 50 of 1 tool.

code-

players = {}
Humanoids = {}

debounce = false

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
table.insert(players, player)
print(players)
end)
player.CharacterAdded:connect(function(character)
while true do
wait()
for i,v in pairs (players) do
local humanoid = v.Character
table.insert(Humanoids, humanoid)
end
for i,v in pairs (Humanoids) do
wait()
local humanoid = v:FindFirstChild("Humanoid")
debounce = true
wait()
local PlayerName = v.Name
local player = game.Players:FindFirstChild(PlayerName)
local name = v.Name
local x1 = game.Lighting:FindFirstChild("CFrame"..name) -- change to lighting tool name
local x2 = game.Lighting:FindFirstChild("Color"..name) -- change to lighting tool name
local x3 = game.Lighting:FindFirstChild("GravityCoil"..name) -- change to lighting tool name
local x4 = game.Lighting:FindFirstChild("Material"..name) -- change to lighting tool name
local x5 = game.Lighting:FindFirstChild("ResizeTool"..name) -- change to lighting tool name
local x6 = game.Lighting:FindFirstChild("Sword"..name) -- change to lighting tool name
local x7 = game.Lighting:FindFirstChild("RunTool"..name) -- change to lighting tool name
local x8 = game.Lighting:FindFirstChild("Teleport"..name) -- change to lighting tool name
local x9 = game.Lighting:FindFirstChild("Anchor"..name) -- change to lighting tool name
if x1 ~= nil and debounce == false then
local xx = game.Lighting.CFrame -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack

end
if x2 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Color -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x3 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.GravityCoil -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x4 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Material -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x5 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.ResizeTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x6 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Sword -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x7 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.RunTool -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x8 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Teleport -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack
end
if x9 ~= nil then
local xx = game.Lighting.CFrame -- change to lighting tool name
local xx = game.Lighting.Anchor -- change to lighting tool name
local tool = xx:Clone()
tool.Parent = player.Backpack

end
debounce = false

end



end
end)


end)
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 09:08 PM
Your script is really confusing to read..
Can you just tell me what you are trying to do
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:11 PM
I made a script saying "Hey when you buy this from the shop GUI you get this tool". But I tried making a script that says "hey when you die you get you tools put back in your backpack."

That easy to understand?
Report Abuse
Infertex is not online. Infertex
Joined: 26 Mar 2012
Total Posts: 895
08 Oct 2014 09:12 PM
Don't use Backpack, try using StarterGUI.

Example:
Tool.Parent = game.StarterGUI
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 09:14 PM
Use your first script and clone the tool into the players Backpack AND another clone into the StarterGear

http://wiki.roblox.com/index.php?title=API:Class/StarterGear
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:41 PM
Nothing seems to be working? If i put into starter gear everyone will get it. I just want them to get it.
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:43 PM
and for some reason when the players buy from shop. When they buy 4 items it glitches. It puts the first three items in ordered slots 1-3 then 4th is in 0 slot and if you buy anything after that you have to press "`" key to see the rest in your backpack
Report Abuse
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
08 Oct 2014 09:46 PM
Player.StarterGear anyone? Basically a starter pack for a player. It would be perfect for this application.

-Vanilla
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:47 PM
I wish they had it
Report Abuse
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
08 Oct 2014 09:49 PM
They do, it's in the player.

http://wiki.roblox.com/index.php?title=StarterGear

-Vanilla
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 09:51 PM
How do i call it? I tried to call it.

Can you call it like this?

game.Players.LocalPlayer.StarterPack?
Report Abuse
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
08 Oct 2014 09:55 PM
Easy.

local tool = game.ServerStorage.foo
tool:Clone().Parent = player.StarterGear
tool:Clone().Parent = player.Backpack

Make sure to do both.

-Vanilla
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
08 Oct 2014 10:32 PM
Thanks works great! One problem tho... When you buy more than four items this happens?

http://www.roblox.com/2014-10-08-23-27-25-ROBLOX-Studio-Place1-item?id=181489334

http://www.roblox.com/2014-10-08-23-28-01-ROBLOX-Studio-Place1-item?id=181489346

when you reset it stays the same? Only way to fix is manual fix. This happens as well-

http://www.roblox.com/11-item?id=181489530
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
09 Oct 2014 12:46 AM
So when I suggest it
Use your first script and clone the tool into the players Backpack AND another clone into the StarterGear

http://wiki.roblox.com/index.php?title=API:Class/StarterGear

It doesn't work

But when someone else does

It works

o3o
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
09 Oct 2014 11:51 AM
What you just said confused me. So I made two script.. The same script but one you pay for the item and it goes into your backpack and another that inserts item into you starter gear... Still does it tho

Ex.

Script1 -

script.Parent.MouseButton1Click:connect(function()
local debounce = true
local found = nil
local points = game.Players.LocalPlayer.leaderstats:FindFirstChild("Points")
if points ~= nil then
local price = script.Parent.Price
if points.Value >= price.Value then
ToolName = script.Parent.ToolName.Value
local StarterGear = game.Players.LocalPlayer.StarterGear
local Backpack = game.Players.LocalPlayer.Backpack
local Character = game.Players.LocalPlayer.Character
local ToolName1 = Instance.new("StringValue")
ToolName1.Parent = script.Parent
ToolName1.Value = ToolName
for i, v in pairs (Backpack:GetChildren()) do
if v.Name == ToolName then
found = true
wait()
end
end
for i, v in pairs (Character:GetChildren()) do
if v.Name == ToolName then
found = true
wait()
end
end
for i, v in pairs (Character:GetChildren()) do
if v.Name == ToolName then
found = true
wait()
end
end
if found == nil then
found = false
end
end
debounce = false
local PlayerName = game.Players.LocalPlayer.Character.Name
if found == false and debounce == false then
if ToolName == "CFrame" then -- change name to item lighting tool name
local tool1 = game.Lighting.CFrame:Clone()
tool1.Parent = game.Players.LocalPlayer.StarterGear
points.Value = points.Value - price.Value
local Bought = Instance.new("BoolValue")
Bought.Parent = game.Lighting
Bought.Name = "CFrame"..PlayerName -- change to lighting tool name
Bought.Value = true
end
end
end
end)


same for script 2 buy clones into backpack and points.value = points.value - price . value is removed
Report Abuse
adeep is not online. adeep
Joined: 06 Feb 2010
Total Posts: 274
09 Oct 2014 12:08 PM
I published it and tested it and i guess it only glitches in studio. Thanks for all your patience and help everyone!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image