Hello! my name is bullet, and today i’ve ran into yet another problem.
I was working on a tag system for items in a factorylike game, and it works for every system except the selling part.
So it refines, then manufactures this item, carrying the tag over each one, and then at the end, the tag is there [ it’s a texture ], it has the player’s name, and yet when it hits the sell pad, it gives it an error.
the code that is erroring: print(Item:FindFirstChildOfClass("Texture").Name)
although, this code works on every other thing, including the tag carryover system.
i just don’t understand why it’s erroring, as it doesn’t error on any other thing if i put it in there.
the rest of the code:
local debounce = true
function Main(Item)
if debounce then
print(Item.Name)
debounce = false
script.Parent.CanCollide = true
script.Parent.Color = Color3.fromRGB(255, 255, 0)
local player = game.Players:FindFirstChild(Item:FindFirstChildOfClass("Texture").Name)
Item:Destroy()
player:WaitForChild("leaderstats"):WaitForChild("TESTINGCURRENCY").Value += 10
wait(0.5)
script.Parent.Color = Color3.fromRGB(0, 255, 0)
script.Parent.CanCollide = false
debounce = true
end
end
script.Parent.Touched:Connect(function(Item)
if Item.Name == "Shovel" then
Main(Item)
print(Item:FindFirstChildOfClass("Texture").Name)
end
end)
thanks for reading, and please help if you can!
if you want the other one’s codes, then just ask.
What you are doing is defining the ‘Item’ as some sort hit. Instead of saying:
script.Parent.Touched:Connect(function(Item)
if Item.Name == "Shovel" then
Main(Item)
print(Item:FindFirstChildOfClass("Texture").Name)
end
end)
You would do this instead:
script.Parent.Touched:Connect(function(Item)
if Item.Parent.Name == "Shovel" then
Main(Item.Parent)
print(Item.Parent:FindFirstChildOfClass("Texture").Name)
end
end)
local players = game:GetService("Players")
local part = script.Parent
local debounce = false
local function mainMethod(item)
if debounce then
return
end
debounce = true
part.CanCollide = true
part.Color = Color3.new(1, 1, 0)
item:Destroy()
task.wait(0.5)
part.Color = Color3.new(0, 1, 0)
part.CanCollide = false
debounce = false
end
part.Touched:Connect(function(hit)
if hit.Parent.Name == "Shovel" then
mainMethod(hit.Parent)
end
end)