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

Why doesn't the remove feature doesn't remove the tool out of the users inventory when clicked on?

Asked by 5 years ago

local Clickdetector = script.Parent:WaitForChild("ClickDetector")

local ToolNames = {"Milk"}

function playerAdded (player)

if player.Name == "Player" then

wait(2)

Clickdetector.MouseClick:Connect(function(Player)

if Player and Player.Character then

if ToolNames then

game.Players.player.Backpack.Milk:remove ()

end

end

end)

end

end

1 answer

Log in to vote
-1
Answered by
Creacoz 210 Moderation Voter
5 years ago
Edited 5 years ago
  local ToolNames = {"Milk"}



function Clicked(Player)

if Player and Player.Character and ToolNames then

for i,z in pairs(game:GetService("Players"):GetPlayers()) do

for i,v in pairs(ToolNames) do

z.Character.Humanoid:UnequipTools()

z.Backpack:FindFirstChild(v):Destroy()

end

end

end

end





script.Parent.ClickDetector.MouseClick:connect(Clicked)

The script receives if the player touched. If he touched then the script will get every player by using for I,z in pairs with players, then will take every toolnames by doing for I,v in pairs. After the script will unequip the tools and remove 1 tool with the name of Milk.

0
This script works but it destroys everything in my inventory (which I only want it to destroy one) and it is player specific (want it to be non-player specific) ufiduduj 19 — 5y
0
So you want it to destroy only one for everyone? Creacoz 210 — 5y
0
There we go! Updated the script. Creacoz 210 — 5y
0
It doesn't even remove anything out of my inventory :( ufiduduj 19 — 5y
View all comments (16 more)
0
You need something called "Milk" Creacoz 210 — 5y
0
I have the "Milk" in the server storage and ufiduduj 19 — 5y
0
you need it in your inventory Creacoz 210 — 5y
0
I do but it the script doesnt remove it ufiduduj 19 — 5y
0
Error? Where did you put the script? Creacoz 210 — 5y
0
inside a guy's arm, the "milk" is a tool and im trying to remove the milk from the player as if they are giving the milk. ufiduduj 19 — 5y
0
is there an error because it works for me, if it really doesnt work ill make a model Creacoz 210 — 5y
0
k thank you ufiduduj 19 — 5y
0
Did you change the playername to yours? Creacoz 210 — 5y
0
Wait now try the script i updated it Creacoz 210 — 5y
0
k ufiduduj 19 — 5y
0
Thanks it works now. Im new to this site, do you know how to verify answers. ufiduduj 19 — 5y
0
Its right under here, if you are using chrome it wont work. So use edge for now just to accept my answer :) Creacoz 210 — 5y
0
-1. No explanation was given. User#24403 69 — 5y
0
Here I explained! If you could remove the -1 it would be really appreciated because I took alot of time to do this and talking with him. I tried my best at explaining :) Creacoz 210 — 5y
Ad

Answer this question