fvtrev
(rev)
June 25, 2024, 6:51am
#1
i have a script where if you click on a tool that is in workspace, you pick it up and it’s supposed to appear in your inventory
the issue is, when i click the tool, it disappears and doesn’t appear in my inventory.
ive tried to use different scripts, but still the same issue reoccurs.
here is the script i use
local tool = script.Parent
local click = tool.ClickDetector
click.MouseClick:Connect(function(player)
tool.Parent = player.Backpack
end)
it gives me an error in output too, here it is.
and when i click the error, it took me to the script i use that when i equip the tool, a UI opens which is what i need. this is my script for the tool when equipped a UI opens;
local Ui = script:WaitForChild("DrawGui")
script.Parent.Equipped:Connect(function()
local ScreenGui = Ui:Clone()
ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui
end)
script.Parent.Unequipped:Connect(function()
game.Players.LocalPlayer.PlayerGui:FindFirstChild(Ui.Name):Destroy()
end)
please help, i need this project done by today.
1 Like
notsad2
(nots7d)
June 25, 2024, 7:00am
#2
try storing the clone of it in a variable, destroy the original, put the replica inside the player’s backpack
well, .Equipped works on tools, and script.Parent
seems to be handle, try doing script.Parent.Parent
(assuming the handle is inside the tool)
fvtrev
(rev)
June 25, 2024, 7:01am
#3
i tried to do script.parent.parent and the tool didnt respond, not disappearing nor going into my backpack. also can u give me an example on how to do what u said on the top im kinda new to scripting and have no idea how to store a clone of it in a variable and stuff
notsad2
(nots7d)
June 25, 2024, 7:04am
#4
programming is a world of magic, can i see your tool in the explorer or something (gonna try to find the cause of this), additionally i’m gonna ask if all the parts in your tool are welded together (not anchored)
uhhhh
local clonedTool = originalTool:Clone()
originalTool:Destroy()
clonedTool.Parent = player.Backpack
fvtrev
(rev)
June 25, 2024, 7:05am
#5
where do i put this
and this is where i put my tool
fvtrev
(rev)
June 25, 2024, 7:05am
#6
the folder is in workspace, by the way
notsad2
(nots7d)
June 25, 2024, 7:07am
#7
uh you put that in clicktopickup
inside the .MouseClick
event
click.MouseClick:Connect(function(player)
local clonedTool = originalTool:Clone()
originalTool:Destroy()
clonedTool.Parent = player.Backpack
end)
fvtrev
(rev)
June 25, 2024, 7:08am
#8
do i replace the tool.Parent = player.Backpack with the script u gave, or do i add it under the already existing line inside the .mouseclick event
notsad2
(nots7d)
June 25, 2024, 7:10am
#9
yeah you replace that
character limit character limit wetjoiajjhroghsaoughfsdpugd
1 Like
fvtrev
(rev)
June 25, 2024, 7:13am
#10
i replaced the “tool.Parent = player.Backpack” under the mouseclick event and it showed me this error when i tried to click it.
this is also how the script looks with it idk if i did something wrong
notsad2
(nots7d)
June 25, 2024, 7:15am
#11
boy what the hell boy
replace originalTool
with your tool
variable
originalTool
is your actual tool variable!!!
fvtrev
(rev)
June 25, 2024, 7:16am
#12
opps LOL mb rgfKJEWLGEQTHBQEHBL CHARACRTER
14zeb
(ron)
June 25, 2024, 7:16am
#13
replace
script.Parent.Equipped
with
script.Parent.Parent.Equipped
You’re referencing the handle which doesn’t have the equipped property. It should be the tool which I assume is the parent of the handle
Edit: Oops, sorry. I didn’t realize you already tried it
2 Likes
notsad2
(nots7d)
June 25, 2024, 7:17am
#14
wait
why do you have 2 functions
that’s not the way to do it
click.MouseClick:Connect(function(player)
local clonedTool = tool:Clone()
tool:Destroy()
clonedTool.Parent = player.Backpack
Hopper bins may help you with this
1 Like
fvtrev
(rev)
June 25, 2024, 7:19am
#16
i am a little dumb uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh one minute please
1 Like
notsad2
(nots7d)
June 25, 2024, 7:21am
#17
what is a hopper bin and what do they help with
fvtrev
(rev)
June 25, 2024, 7:21am
#18
so uh i fixed it up and everything and when i click it doesnt do anything and nothing appears in output
It’s a hopping bin and it can hop into your backpack
notsad2
(nots7d)
June 25, 2024, 7:22am
#20
what is this space alien problem
can you put a print("i have been clicked and i do not work!")
right at the start of that function
oh wait, looking at the explorer rn
the parent of the click script is Handle
right?
try doing tool = script.Parent.Parent
instead, otherwise that code will only run upon clicking the handle (Which is bad!!!)