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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Clear ALL BACKPACK on touch (FE)

Previous Thread :: Next Thread 
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:10 AM
Could someone PLEASE reply with a script i can put in a block so when someone touches it all their tools in their backpack (INCLUDING THE ONE THEY ARE HOLDING) dissapear.

Thankyou for your help!



HiddenTaxes
Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
10 Aug 2017 01:14 AM
please stop creating threads for each individual request asking people to give you free things

we are not your code monkeys - if you want to ask for free code do it through private message, it's better for everyone that way

:^)


Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:15 AM
Im asking for people to be nice and help. Clearly not people like you. All I need is help.


HiddenTaxes
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
10 Aug 2017 01:18 AM
http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched
http://wiki.roblox.com/index.php?title=API:Class/Instance/ClearAllChildren
Report Abuse
TinyGravity is not online. TinyGravity
Joined: 30 Apr 2016
Total Posts: 262
10 Aug 2017 01:23 AM
p = script.Parent

script.Parent.Touched:Connect(function(part)
if part.Parent and part.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
local bp = plr:FindFirstChild("BackPack")
if plr and bp then
for i,v in pairs(bp:GetChildren()) do
v:Destroy()
end
for i,v in pairs(plr.Character:GetChildren()) do
if v.ClassName == "Tool" then
v:Destroy()
end
end
end
end
end)
Report Abuse
Wrathsong is online. Wrathsong
Joined: 05 Jul 2012
Total Posts: 22393
10 Aug 2017 01:27 AM
there's a difference between a help request (when you're *trying* to work through a problem, are stuck on something and don't know how to proceed) and what you're doing


Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
10 Aug 2017 01:35 AM
Help does not equal someone doing the work for you.

Also, 'nice' people doesn't mean a person that does free labor for you.


Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:37 AM
It depends how you define 'help'. Im having trouble scripting this and reached out for some help


HiddenTaxes
Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 01:38 AM
you have been placed on the anti-priority list.
Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
10 Aug 2017 01:40 AM
If you had trouble scripting it, you could at least post your script and we can debug it for you so you learn from your mistakes and explain better ways of approaching it.


Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:44 AM
Alright, here you go (if ur willing to help) I have the script, but when i touch the block, it doesnt take the item I am holding...

function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) then
local hit.Parent.Name
h=game.Players:findFirstChild(g).Backpack:getChildren()
for i=1, #h do
h[i]:remove(1)
end
end
end




script.Parent.Touched:connect(onTouched)




HiddenTaxes
Report Abuse
TinyGravity is not online. TinyGravity
Joined: 30 Apr 2016
Total Posts: 262
10 Aug 2017 01:45 AM
HiddenTaxes = Roblox.Users.HiddenTaxes

if HiddenTaxes.Robux.Value >= 0 then
print("Can I have some robux for helping you?")
end
Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 01:47 AM
the first things to fix are:

FindFirstChild instead of findFirstChild
GetChildren instead of getChildren
Destroy instead of remove
Connect instead of connect
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:50 AM
Sorry, that one was the broken one, can u change this so it works with FE?

function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if (human ~= nil) then
g=hit.Parent.Name
h=game.Players:FindFirstChild(g).Backpack:GetChildren()
for i=1, #h do
h[i]:Destroy()
end
end
end

script.Parent.Touched:Connect(onTouched)


HiddenTaxes
Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 01:52 AM
now before your code you want to get the players service

local players = game:GetService("Players")

and instead of defining the Humanoid, define the Character

local character = hit.Parent

now get the player

local player = players:GetPlayerFromCharacter(character)
if player then
--code
end

at this point, where --code is, you need to fire a remote event to the client which you just got, and then in a local script clear their backpack when that event is received.
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 01:55 AM
Its looking like this now:

local players = game:GetService("Players")
function onTouched(hit)
local character = hit.Parent
if (character ~= nil) then
local player = players:GetPlayerFromCharacter(character)
if player then
--code
end
end
end


script.Parent.Touched:Connect(onTouched)

BTW Im really new to scripting, I have close to no idea how to do 'events/remote events'


HiddenTaxes
Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
10 Aug 2017 01:58 AM
When a player 'holds' a tool, the tool is located in the Character (unless it is a hopperbin, that will be located in the Backpack).

So you would run a loop through the character and destroy all objects that are tools.

for _, v in next, Character:GetChildren() do --Loop through Character objects
if (v.ClassName == 'Tool') then --if that object is a tool
v.Parent = Player.Backpack --parent it to backpack
v:Destroy() --destroy it
end
end

You would parent it back to Player.Backpack because if the tool has an Unequipped event, it can fire before you can destroy it.


Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 02:00 AM
well

that's fundamental to using FE

so its not a good idea to go into creating a script thats fe compatible, if you don't know anything about fe or how to use it.

i recommend reading this wiki page

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

as an additional tip

instead of looping through the backpack, use ClearAllChildren.

and one more:

the tool the player is holding isn't in the backpack, it is in the character model.
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 02:00 AM
Thanks guys for ur help, because scripting is like learning a new language (to me) could u write me a set of instructions on exactly where to put the script u gave me? I am completely hopeless...


HiddenTaxes
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 02:06 AM
Thankyou so much for you help!


HiddenTaxes
Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 02:06 AM
this is not the place for handouts

if you give up on scripting, ask questions instead of asking for people to fix your code

ask "why doesn't this work" instead of "what is the right code?"

this way I would say something like "you need a remote event"

and then you say "i don't understand remote events"

and then i say "here is a link"

and then you learn it

and then you come back and say "why doesn't this work?"

and then we would explain what you did wrong with remote events

and you would learn instead and one day you might be an okay scripter instead of following your current path
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 02:09 AM
Thankyou for ur wisdom! I am reading the wiki and will have a go.


HiddenTaxes
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 02:11 AM
There are MANY scripts on the Wiki, do I need to place all of them in my Folder in Replicated Storage under my RemoteEvent? Whats the best and easiest way to put it all together?


HiddenTaxes
Report Abuse
Dadosayhi is not online. Dadosayhi
Joined: 05 Jul 2011
Total Posts: 272
10 Aug 2017 02:15 AM
well

notice above and below the scripts there are words


the remote event goes in replicated storage

a regular script goes in the part

a local script goes in starter player scripts

you are looking at remote events, and you will be using FireClient with the player you just got in your script as an argument

and OnClientEvent in your local script
Report Abuse
HiddenTaxes is not online. HiddenTaxes
Joined: 30 Nov 2015
Total Posts: 115
10 Aug 2017 02:18 AM
Alright, ill see what i can do from here :D


HiddenTaxes
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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