Okay, please show the whole script
local Num = 0
function onTouched(Bean)
if Bean.Parent == workspace.Conveyor.CocoaBeans then
Bean.Parent = script.Parent.Parent.CocoaBeans
Num = Num+1
local Weld = Instance.new("Weld")
Weld.Parent = script.Parent.Welds
Weld.Part0 = Bean
Weld.Part1 = script.Parent
if Num == 1 then
script.Parent.Parent.Lid.CanCollide = true
script.Parent.Parent.Lid.Transparency = 0
script.Parent.Parent.Lid.Script:Destroy()
script.Parent.Parent.Lid.ClickDetector:Destroy()
local Tool = Instance.new("Tool")
Tool.Name = ("Box")
script.Parent.Parent.Parent = Tool
Tool.Parent = workspace.Transportation
function onTouched(hit)
local player = game.Players:GetPlayersFromCharacter(hit.Parent)
if player then
Tool.Parent = player.Backpack
end
end
script.Parent.Touched:Connect(onTouched)
end
end
end
script.Parent.Touched:connect(onTouched)
do you want me to explain what the script does?
You have made a touched function inside of another touched function, which shouldn’t be the case. Put the onTouched(hit)
function outside of the onTouched(Bean)
function along with the script.Parent.Touched:Connect(onTouched)
could you repeat that in a easier way please i am not very good with scripting
Use this:
local Num = 0
function onTouched(Bean)
if Bean.Parent == workspace.Conveyor.CocoaBeans then
Bean.Parent = script.Parent.Parent.CocoaBeans
Num = Num+1
local Weld = Instance.new("Weld")
Weld.Parent = script.Parent.Welds
Weld.Part0 = Bean
Weld.Part1 = script.Parent
if Num == 1 then
script.Parent.Parent.Lid.CanCollide = true
script.Parent.Parent.Lid.Transparency = 0
script.Parent.Parent.Lid.Script:Destroy()
script.Parent.Parent.Lid.ClickDetector:Destroy()
local Tool = Instance.new("Tool")
Tool.Name = ("Box")
script.Parent.Parent.Parent = Tool
Tool.Parent = workspace.Transportation
end
end
end
script.Parent.Touched:connect(onTouched)
function onTouched(hit)
local player = game.Players:GetPlayersFromCharacter(hit.Parent)
if player then
Tool.Parent = player.Backpack
end
end
script.Parent.Touched:Connect(onTouched)
1 Like
oh wait i have fixed it the problem was the Handle was not the direct child of the tool so i made it and i d=fixed it thanks BabyNinja Time
local Num = 0
function onTouched(Bean)
if Bean.Parent == workspace.Conveyor.CocoaBeans then
Bean.Parent = script.Parent.Parent.CocoaBeans
Num = Num+1
local Weld = Instance.new("Weld")
Weld.Parent = script.Parent.Welds
Weld.Part0 = Bean
Weld.Part1 = script.Parent
if Num == 1 then
script.Parent.Parent.Lid.CanCollide = true
script.Parent.Parent.Lid.Transparency = 0
script.Parent.Parent.Lid.Script:Destroy()
script.Parent.Parent.Lid.ClickDetector:Destroy()
local Tool = Instance.new("Tool")
Tool.Name = ("Box")
script.Parent.Parent.Parent = Tool
Tool.Parent = workspace.Transportation
local Handle = workspace.Transportation.Box.Crate.Handle
Handle.Parent = Tool
function onTouched(hit)
local player = game.Players:GetPlayersFromCharacter(hit.Parent)
if player then
Tool.Parent = player.Backpack
end
end
script.Parent.Touched:Connect(onTouched)
end
end
end
script.Parent.Touched:connect(onTouched)
1 Like