Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you remove an item from a player's Starterpack when they step on a brick?

Asked by 6 years ago

I am just beginning in Lua and I really need some help on how to remove an item from the StarterPack when a player steps on a brick. Also, the item is called TPTool. My game is filtering enabled and i'm not quite sure what to do.

0
So would you want it so it removes from the starterpack service or from their backpack as if you remove it from starterpack service, when someone joins the game they won't be able to get that item. TypicallyPacific 61 — 6y
0
Are you talking about a single player's starterpack or multiple? NoLife_David 1 — 6y
0
I just want the gear to be removed, not permanently and make it so if they die, they get the gear back User#23357 0 — 6y
0
Try my script again. CaptainD_veloper 290 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I'm nowhere near an expert scripter, so please bare in mind with my messy script.

First you should insert a ServerScript into a brick.

01local Players = game:GetService("Players")
02 
03script.Parent.Touched:Connect(function(hit) --when the player touches the part
04local humanoid = hit.Parent:FindFirstChild("Humanoid") --finds the humanoid through the part that hit the brick, meaning that it finds the parent of the part that touched it and searches for a humanoid
05local player = Players:GetPlayerFromCharacter(humanoid.Parent) --gets the player through the humanoid's parent, which is the character
06local TPTool = player.Backpack:FindFirstChild("TPTool") --searches for the tool inside of the player's backpack
07if TPTool ~= nil then --basically means if the script finds the tool inside of the backpack
08    TPTool:Destroy() --destroys the tool
09    end
10end)

Might be some errors, but I'm not sure..

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Try this script:

01local ting = 0
02 
03function onTouched(hit)
04 
05    if ting == 0 then
06    ting = 1
07    check = hit.Parent:FindFirstChild("Humanoid")
08 
09    if check ~= nil then
10 
11        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
12        local tptool= player.StarterGear:findFirstChild("TPTool")
13 
14        if tptool~= nil then
15        player.StarterGear.TPTool:Destroy()
View all 26 lines...

Accept this answer if it worked:>.

0
indent correctly Vulkarin 581 — 6y
0
It didn't quite work :T User#23357 0 — 6y
0
^You need to change "leaderstats" on line 12 to whatever the actual tool name is, I'm not sure why it's named that to begin with Vulkarin 581 — 6y
0
It still doesn't seem to work.. User#23357 0 — 6y
View all comments (4 more)
0
Is there any output? Vulkarin 581 — 6y
0
nope ;( User#23357 0 — 6y
0
replace line 12 from `StarterGear` to `Backpack`, remove line 15, change line 16 to just `tptool:Destroy()` Vulkarin 581 — 6y
0
You need to explain the script. and :connect and :findFirstChild is deprecated. use: :Connect and :FindFirstChild, also you can use if check then and if tptool then dont need to use if check ~= nil then and if tptool ~= nil then yHasteeD 1819 — 6y

Answer this question