Basically I want a script that gives you a gear from Lighting when you touch a certain part, then removes that part you just touched.
The gear in Lighting and part in Workspace also have a StringValue inside of them.
The value inside of the gear in Lighting is blank, as I want it to copy the value from the part in the Workspace.
I can somewhat get the script to work when it is inside of the part, but not at all when the script is in the Workspace. The most it has done is give me the item..
Current Script: (Inside of Workspace)
function touch(hit)
local item2 = game.Lighting.Storage.MountainDew
local debounce = false
script.Parent.Touched:connect(function(part)
if hit.Name == game.Workspace:FindFirstChild("MountainDew") ~= true then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player ~= nil then
if player.Backpack ~= nil then
if debounce == false then
debounce = true
item2:Clone().Parent = player.Backpack
hit.Name = "To: " .. (game.MountainDew.House.Value)
hit.House.Value = game.MountainDew.House.Value
game.Workspace.MountainDew:remove()
wait(3)
debounce = false
end
end
end
end
end)
end
script.Parent.Touched:connect(touch)
Im so confused on why it's not working. If anyone could help, that would be great.

2 comments
Hey. Thank you man. :)
Hey. Thank you man. :) It worked perfectly. I also added "script.Parent:Remove()", which removes the part just like I wanted.